/*
 * second_harmonic_generation.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 15 2026, 12:08 by COMSOL 6.4.0.421. */
public class second_harmonic_generation {

  public static Model run() {
    Model model = ModelUtil.create("Model");

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 2D.
//    In the Select Physics tree, select Radio Frequency > Electromagnetic Waves, Transient (temw).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Time Dependent.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").geom().create("geom1", 2);

    model.component("comp1").mesh().create("mesh1");

    model.component("comp1").physics().create("temw", "TransientElectromagneticWaves", "geom1");

    model.study().create("std1");
    model.study("std1").create("time", "Transient");

//    In the Model Builder window, under Component 1 (comp1), click Geometry 1.
//    In the Settings window for Geometry, locate the Units section.
//    From the Length unit list, select µm.

    model.component("comp1").geom("geom1").lengthUnit("\u00b5m");

//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, locate the Parameters section.
//    In the table, enter the following settings:

    model.param().set("w0", "2[um]");
    model.param().descr("w0", "Minimum spot radius of laser beam");
    model.param().set("lda0", "1.06[um]");
    model.param().descr("lda0", "Wavelength of input laser beam");
    model.param().set("E0", "30[kV/m]");
    model.param().descr("E0", "Peak electric field");
    model.param().set("x0", "pi*w0^2/lda0");
    model.param().descr("x0", "Rayleigh range");
    model.param().set("k0", "2*pi/lda0");
    model.param().descr("k0", "Propagation constant");
    model.param().set("omega0", "k0*c_const");
    model.param().descr("omega0", "Angular frequency");
    model.param().set("t0", "25[fs]");
    model.param().descr("t0", "Pulse time delay");
    model.param().set("dt", "10[fs]");
    model.param().descr("dt", "Pulse width");
    model.param().set("d33", "1e-17[F/V]");
    model.param().descr("d33", "Matrix element for second harmonic generation");
    model.param().set("lda2", "lda0/2");
    model.param().descr("lda2", "Wavelength for second harmonic");
    model.param().set("hmax", "lda2/6");
    model.param().descr("hmax", "Maximum mesh element size");
    model.param().set("CFL", "0.15");
    model.param().descr("CFL", "CFL number");
    model.param().set("tstep", "CFL*hmax/c_const");
    model.param().descr("tstep", "Time step");

//    The last four parameters will be used for defining the maximum mesh element size and for defining the time step for the time-dependent solver.
//    In the Home toolbar, click Functions and choose Global > Analytic.

    model.func().create("an1", "Analytic");

//    In the Settings window for Analytic, type w in the Function name text field.

    model.func("an1").set("funcname", "w");

//    Locate the Definition section.
//    In the Expression text field, type w0*sqrt(1+(x/x0)^2).

    model.func("an1").set("expr", "w0*sqrt(1+(x/x0)^2)");

//    Locate the Units section.
//    In the table, enter the following settings:

    model.func("an1").setIndex("argunit", "m", 0);

//    In the Function text field, type m.

    model.func("an1").set("fununit", "m");

//    In the Home toolbar, click Functions and choose Global > Analytic.

    model.func().create("an2", "Analytic");

//    In the Settings window for Analytic, type eta in the Function name text field.

    model.func("an2").set("funcname", "eta");

//    Locate the Definition section.
//    In the Expression text field, type atan2(x,x0)/2.

    model.func("an2").set("expr", "atan2(x,x0)/2");

//    Locate the Units section.
//    In the table, enter the following settings:

    model.func("an2").setIndex("argunit", "m", 0);

//    In the Function text field, type rad.

    model.func("an2").set("fununit", "rad");

//    In the Home toolbar, click Functions and choose Global > Analytic.

    model.func().create("an3", "Analytic");

//    In the Settings window for Analytic, type R in the Function name text field.

    model.func("an3").set("funcname", "R");

//    Locate the Definition section.
//    In the Expression text field, type x*(1+(x0/x)^2).

    model.func("an3").set("expr", "x*(1+(x0/x)^2)");

//    Locate the Units section.
//    In the table, enter the following settings:

    model.func("an3").setIndex("argunit", "m", 0);

//    In the Function text field, type m.

    model.func("an3").set("fununit", "m");

//    Create a rectangular calculation domain, where y = 0 is the symmetry plane for the laser beam.
//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r1", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type 20.

    model.component("comp1").geom("geom1").feature("r1").set("size", new double[]{20, 1});

//    In the Height text field, type 6.

    model.component("comp1").geom("geom1").feature("r1").set("size", new double[]{20, 6});

//    Locate the Position section.
//    In the x text field, type -10.

    model.component("comp1").geom("geom1").feature("r1").set("pos", new double[]{-10, 0});

//    In the y text field, type -6.

    model.component("comp1").geom("geom1").feature("r1").set("pos", new double[]{-10, -6});

//    Click Build All Objects.

    model.component("comp1").geom("geom1").runPre("fin");

//    Click the Zoom Extents button in the Graphics toolbar.

    model.component("comp1").geom("geom1").run();

//    Assume that the laser beam propagates through an artificial material with the properties of air except for an additional second-order optical nonlinearity. You will specify the nonlinearity later, when setting up the wave equation.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Air.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat1", "Common");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("eta", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("rho", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("k", "Piecewise");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("cs", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("an1", "Analytic");
    model.component("comp1").material("mat1").propertyGroup("def").func().create("an2", "Analytic");
    model.component("comp1").material("mat1").propertyGroup()
         .create("RefractiveIndex", "RefractiveIndex", "Refractive index");
    model.component("comp1").material("mat1").propertyGroup()
         .create("NonlinearModel", "NonlinearModel", "Nonlinear model");
    model.component("comp1").material("mat1").propertyGroup().create("idealGas", "idealGas", "Ideal gas");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func().create("Cp", "Piecewise");
    model.component("comp1").material("mat1").label("Air");
    model.component("comp1").material("mat1").set("family", "air");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta")
         .set("pieces", new String[][]{{"200.0", "1600.0", "-8.38278E-7+8.35717342E-8*T^1-7.69429583E-11*T^2+4.6437266E-14*T^3-1.06585607E-17*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("eta").set("fununit", "Pa*s");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp")
         .set("pieces", new String[][]{{"200.0", "1600.0", "1047.63657-0.372589265*T^1+9.45304214E-4*T^2-6.02409443E-7*T^3+1.2858961E-10*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("expr", "pA*0.02897/R_const[K*mol/J]/T");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho").set("fununit", "kg/m^3");
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("rho")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "293.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("def").func("k")
         .set("pieces", new String[][]{{"200.0", "1600.0", "-0.00227583562+1.15480022E-4*T^1-7.90252856E-8*T^2+4.11702505E-11*T^3-7.43864331E-15*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("def").func("k").set("fununit", "W/(m*K)");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("expr", "sqrt(1.4*R_const[K*mol/J]/0.02897*T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("args", new String[]{"T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("fununit", "m/s");
    model.component("comp1").material("mat1").propertyGroup("def").func("cs").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("plotfixedvalue", new String[]{"273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("cs")
         .set("plotargs", new String[][]{{"T", "273.15", "373.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("funcname", "alpha_p");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("expr", "-1/rho(pA,T)*d(rho(pA,T),T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("args", new String[]{"pA", "T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1").set("fununit", "1/K");
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("argunit", new String[]{"Pa", "K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotaxis", new String[]{"off", "on"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotfixedvalue", new String[]{"101325", "273.15"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an1")
         .set("plotargs", new String[][]{{"pA", "101325", "101325"}, {"T", "273.15", "373.15"}});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("funcname", "muB");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("expr", "0.6*eta(T)");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("args", new String[]{"T"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("fununit", "Pa*s");
    model.component("comp1").material("mat1").propertyGroup("def").func("an2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2")
         .set("plotfixedvalue", new String[]{"200"});
    model.component("comp1").material("mat1").propertyGroup("def").func("an2")
         .set("plotargs", new String[][]{{"T", "200", "1600"}});
    model.component("comp1").material("mat1").propertyGroup("def").set("thermalexpansioncoefficient", "");
    model.component("comp1").material("mat1").propertyGroup("def").set("molarmass", "");
    model.component("comp1").material("mat1").propertyGroup("def").set("bulkviscosity", "");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"alpha_p(pA,T)", "0", "0", "0", "alpha_p(pA,T)", "0", "0", "0", "alpha_p(pA,T)"});
    model.component("comp1").material("mat1").propertyGroup("def").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat1").propertyGroup("def").set("bulkviscosity", "muB(T)");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermeability", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("relpermittivity", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("def").set("dynamicviscosity", "eta(T)");
    model.component("comp1").material("mat1").propertyGroup("def").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("electricconductivity", new String[]{"0[S/m]", "0", "0", "0", "0[S/m]", "0", "0", "0", "0[S/m]"});
    model.component("comp1").material("mat1").propertyGroup("def").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat1").propertyGroup("def").set("density", "rho(pA,T)");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalconductivity", new String[]{"k(T)", "0", "0", "0", "k(T)", "0", "0", "0", "k(T)"});
    model.component("comp1").material("mat1").propertyGroup("def").set("soundspeed", "cs(T)");
    model.component("comp1").material("mat1").propertyGroup("def").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("def").addInput("pressure");
    model.component("comp1").material("mat1").propertyGroup("RefractiveIndex")
         .set("n", new String[]{"1", "0", "0", "0", "1", "0", "0", "0", "1"});
    model.component("comp1").material("mat1").propertyGroup("NonlinearModel").set("BA", "def.gamma-1");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").label("Piecewise 2");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("arg", "T");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp")
         .set("pieces", new String[][]{{"200.0", "1600.0", "1047.63657-0.372589265*T^1+9.45304214E-4*T^2-6.02409443E-7*T^3+1.2858961E-10*T^4"}});
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("argunit", "K");
    model.component("comp1").material("mat1").propertyGroup("idealGas").func("Cp").set("fununit", "J/(kg*K)");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("Rs", "R_const/Mn");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("heatcapacity", "Cp(T)");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("ratioofspecificheat", "1.4");
    model.component("comp1").material("mat1").propertyGroup("idealGas").set("molarmass", "0.02897[kg/mol]");
    model.component("comp1").material("mat1").propertyGroup("idealGas").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("idealGas").addInput("pressure");
    model.component("comp1").material("mat1").materialType("nonSolid");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    Only solve for the out-of-plane component.
//    In the Settings window for Electromagnetic Waves, Transient, locate the Components section.
//    From the Electric field components solved for list, select Out-of-plane vector.

    model.component("comp1").physics("temw").prop("components").set("components", "outofplane");

//    In the Physics toolbar, click Boundaries and choose Perfect Magnetic Conductor.

    model.component("comp1").physics("temw").create("pmc1", "PerfectMagneticConductor", 1);

//    Select Boundary 3.

    model.component("comp1").physics("temw").feature("pmc1").selection().set(3);

//    In the Physics toolbar, click Boundaries and choose Scattering Boundary Condition.

    model.component("comp1").physics("temw").create("sctr1", "Scattering", 1);

//    Select Boundary 1.

    model.component("comp1").physics("temw").feature("sctr1").selection().set(1);

//    In the Settings window for Scattering Boundary Condition, locate the Scattering Boundary Condition section.
//    From the Incident field list, select Wave given by E field.

    model.component("comp1").physics("temw").feature("sctr1").set("IncidentField", "EField");

//    Specify the \[\mathbf{E}_0\] vector as

    model.component("comp1").physics("temw").feature("sctr1")
         .set("E0i", new String[]{"0", "0", "E0*sqrt(w0/w(x))*exp(-y^2/w(x)^2)*cos(omega0*t-k0*x+eta(x)-k0*y^2/(2*R(x)))*exp(-(t-t0)^2/dt^2)"});

//    In the Physics toolbar, click Boundaries and choose Scattering Boundary Condition.

    model.component("comp1").physics("temw").create("sctr2", "Scattering", 1);

//    Select Boundary 4.

    model.component("comp1").physics("temw").feature("sctr2").selection().set(4);

//    In the Model Builder window, click Wave Equation, Electric 1.
//    In the Settings window for Wave Equation, Electric, locate the Electric Displacement Field section.
//    From the Electric displacement field model list, select Remanent electric displacement.

    model.component("comp1").physics("temw").feature("wee1").set("DisplacementFieldModel", "RemanentDisplacement");

//    Specify the \[\mathbf{D}_{\textrm{r}}\] vector as

    model.component("comp1").physics("temw").feature("wee1").set("Dr", new String[]{"0", "0", "d33*temw.Ez^2"});

//    In the Mesh toolbar, click Mapped.

    model.component("comp1").mesh("mesh1").create("map1", "Map");

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("map1").create("dis1", "Distribution");

//    Select Boundaries 1, 4.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection().set(1, 4);

//    In the Settings window for Distribution, locate the Distribution section.
//    From the Distribution type list, select Explicit.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("type", "explicit");

//    In the Relative placement of vertices along edge text field, type sin(range(0,0.025*pi,0.5*pi)).

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1")
         .set("explicit", "sin(range(0,0.025*pi,0.5*pi))");

//    . This creates a denser mesh closer to the upper boundary.
//    In the Model Builder window, under Component 1 (comp1) > Mesh 1, click Size.
//    In the Settings window for Size, locate the Element Size section.
//    Click the Custom button.

    model.component("comp1").mesh("mesh1").feature("size").set("custom", true);

//    Locate the Element Size Parameters section.
//    In the Maximum element size text field, type hmax.

    model.component("comp1").mesh("mesh1").feature("size").set("hmax", "hmax");

//    Click Build All.

    model.component("comp1").mesh("mesh1").run();

//    Click the Zoom Extents button in the Graphics toolbar.
//    To perform an FFT analysis, the number of time steps that have to be saved is very large. To store all solutions of the A-field results in a huge model file. However, for the FFT, it is only interesting to look at the field at the output boundary. You can take advantage of this fact by defining a Domain Point Probe that stores and displays the on-axis electric field at the output boundary, whereas the A-field is only stored at the times defined in the study.
//    In the Definitions toolbar, click Probes and choose Domain Point Probe.

    model.component("comp1").probe().create("pdom1", "DomainPoint");

//    In the Settings window for Domain Point Probe, locate the Point Selection section.
//    In row Coordinates, set x to 10.

    model.component("comp1").probe("pdom1").setIndex("coords2", 10, 0);

//    In the Model Builder window, expand the Domain Point Probe 1 node, then click Point Probe Expression 1 (ppb1).
//    In the Settings window for Point Probe Expression, type Eout in the Variable name text field.

    model.component("comp1").probe("pdom1").feature("ppb1").set("probename", "Eout");

//    Click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Electromagnetic Waves, Transient > Electric > Electric field - V/m > temw.Ez - Electric field, z-component.

    model.component("comp1").probe("pdom1").feature("ppb1").set("expr", "temw.Ez");
    model.component("comp1").probe("pdom1").feature("ppb1").set("descr", "Electric field, z-component");

//    Now define the times for which to save the full field solutions.
//    In the Model Builder window, under Study 1, click Step 1: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type 0 61[fs] 90[fs] 120[fs].

    model.study("std1").feature("time").set("tlist", "0 61[fs] 90[fs] 120[fs]");

//    Click to expand the Results While Solving section.
//    Select the Plot checkbox.

    model.study("std1").feature("time").set("plot", true);

//    In the Study toolbar, click Show Default Solver.

    model.study("std1").showAutoSequences("all");

//    Set the solver to calculate the output field every 0.2 fs.
//    In the Model Builder window, expand the Solution 1 (sol1) node, then click Time-Dependent Solver 1.
//    In the Settings window for Time-Dependent Solver, click to expand the Time Stepping section.
//    From the Steps taken by solver list, select Manual.

    model.sol("sol1").feature("t1").set("tstepsgenalpha", "manual");

//    In the Time step text field, type tstep.

    model.sol("sol1").feature("t1").set("timestepgenalpha", "tstep");

//    In the Model Builder window, expand the Study 1 > Solver Configurations > Solution 1 (sol1) > Time-Dependent Solver 1 node, then click Fully Coupled 1.
//    In the Settings window for Fully Coupled, click to expand the Method and Termination section.
//    Select the Use linear heuristics for adaptive tolerance checkbox.

    model.sol("sol1").feature("t1").feature("fc1").set("useheuristicfact", true);

//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.component("comp1").probe("pdom1").genResult("none");

    model.sol("sol1").runAll();

    model.result().remove("pg2");

    model.study("std1").feature("time").set("plotgroup", "Default");

    model.result().create("pg2", "PlotGroup2D");
    model.result("pg2").set("smooth", "internal");
    model.result("pg2").feature().create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("smooth", "internal");
    model.result("pg2").feature("surf1").set("data", "parent");
    model.result("pg2").run();
    model.result("pg2").run();

//    In the Model Builder window, expand the 2D Plot Group 2 node, then click Surface 1.
//    In the Settings window for Surface, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose temw.Ez - Electric field, z-component - V/m.

    model.result("pg2").feature("surf1").set("expr", "temw.Ez");
    model.result("pg2").feature("surf1").set("descr", "Electric field, z-component");

//    Right-click Surface 1 and choose Height Expression.

    model.result("pg2").feature("surf1").create("hght1", "Height");
    model.result("pg2").run();
    model.result("pg2").run();

//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Time (s) list, select 6.1E-14.

    model.result("pg2").setIndex("looplevel", 2, 0);

//    In the 2D Plot Group 2 toolbar, click Plot.

    model.result("pg2").run();

//    From the Time (s) list, select 9E-14.

    model.result("pg2").setIndex("looplevel", 3, 0);

//    In the 2D Plot Group 2 toolbar, click Plot.

    model.result("pg2").run();

//    Finally, make a spectral analysis of the on-axis electric field at the output boundary.

    model.result("pg1").set("window", "window1");
    model.result("pg1").run();

//    In the Model Builder window, expand the Results > Probe Plot Group 1 node, then click Probe Table Graph 1.
//    In the Settings window for Table Graph, locate the Data section.
//    From the Transformation list, select Discrete Fourier transform.

    model.result("pg1").feature("tblp1").set("transform", "fourier");

//    From the Show list, select Frequency spectrum.

    model.result("pg1").feature("tblp1").set("fouriershow", "spectrum");

//    Select the Frequency range checkbox.

    model.result("pg1").feature("tblp1").set("freqrangeactive", true);

//    In the Probe Plot Group 1 toolbar, click Plot.

    model.result("pg1").set("window", "window1");
    model.result("pg1").run();
    model.result("pg1").set("window", "window1");
    model.result("pg1").run();
    model.result("pg1").set("window", "graphics");
    model.result("pg1").run();
    model.result("pg2").run();

    model.title("Second Harmonic Generation of a Gaussian Beam");

    model
         .description("Laser systems are an important application area in modern electronics. With nonlinear materials it is possible to generate harmonics that are multiples of the frequency of the laser light. This example shows how a second harmonic generation can be set up as a transient wave simulation, using nonlinear material properties. A Nd:YAG (lambda=1.06\u00a0microns) laser beam is focused on a nonlinear crystal, so that the waist of the beam is inside the crystal.");

    return model;
  }

  public static void main(String[] args) {
    run();
  }

}
