/*
 * engine_coolant_properties.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 13 2026, 15:44 by COMSOL 6.4.0.419. */
public class engine_coolant_properties {

  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 Axisymmetric.
//    In the Select Physics tree, select Fluid Flow > Nonisothermal Flow > Turbulent Flow > Turbulent Flow, k-ε.
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Stationary.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").geom().create("geom1", 2);
    model.component("comp1").geom("geom1").axisymmetric(true);

    model.component("comp1").mesh().create("mesh1");

    model.component("comp1").physics().create("spf", "TurbulentFlowkeps", "geom1");
    model.component("comp1").physics("spf").prop("AdvancedSettingProperty").set("UsePseudoTime", "1");
    model.component("comp1").physics("spf").prop("PhysicalModelProperty")
         .set("Compressibility", "WeaklyCompressible");
    model.component("comp1").physics().create("ht", "HeatTransferInFluids", "geom1");
    model.component("comp1").physics("ht").prop("ShapeProperty").set("order_temperature", "1");

    model.component("comp1").multiphysics().create("nitf1", "NonIsothermalFlow", 2);
    model.component("comp1").multiphysics("nitf1").set("Fluid_physics", "spf");
    model.component("comp1").multiphysics("nitf1").set("Heat_physics", "ht");

    model.study().create("std1");
    model.study("std1").create("stat", "Stationary");

//    In the Physics toolbar, click Thermodynamics and choose Thermodynamic System.
//    From the Phase list, select Vapor–liquid.
//    Click Next in the window toolbar.
//    In the Species list, select ethylene glycol (107-21-1, C2H6O2).
//    select ethylene glycol (107-21-1, C2H6O2) in the Species list.
//    Click Add Selected.
//    In the Species text field, type water.
//    In the Species list, select water (7732-18-5, H2O).
//    select water (7732-18-5, H2O) in the Species list.
//    Click Add Selected.
//    Click Next in the window toolbar.
//    From the list, select UNIFAC VLE.
//    From the Gas-phase model list, select Ideal gas.
//    Click Finish in the window toolbar.

    model.thermodynamics().feature().create("pp1", "BuiltinPropertyPackage");
    model.thermodynamics().feature("pp1")
         .set("compoundlist", new String[][]{{"ethylene glycol", "107-21-1", "C2H6O2", "COMSOL"}, {"water", "7732-18-5", "H2O", "COMSOL"}});
    model.thermodynamics().feature("pp1").set("phase_list", new String[][]{{"Vapor", "Vapor"}, {"Liquid", "Liquid"}});
    model.thermodynamics().feature("pp1").label("Vapor\u2013Liquid System 1");
    model.thermodynamics().feature("pp1").set("manager_id", "COMSOL");
    model.thermodynamics().feature("pp1").set("manager_version", "1.0");
    model.thermodynamics().feature("pp1").set("packagename", "pp1");
    model.thermodynamics().feature("pp1").set("package_desc", "Built-in property package");
    model.thermodynamics().feature("pp1").set("managerindex", "0");
    model.thermodynamics().feature("pp1").set("packageid", "COMSOL1");
    model.thermodynamics().feature("pp1").set("ThermodynamicModel", "UNIFAC");
    model.thermodynamics().feature("pp1").set("EOS", "IdealGas");
    model.thermodynamics().feature("pp1").set("LiquidPhaseModel", "UNIFAC");
    model.thermodynamics().feature("pp1").set("LiquidCard", "LiquidPhaseModel");
    model.thermodynamics().feature("pp1").set("EOSModel", "IdealGas");
    model.thermodynamics().feature("pp1").set("GasPhaseModel", "IdealGas");
    model.thermodynamics().feature("pp1").set("GasEOSCard", "GasPhaseModel");
    model.thermodynamics().feature("pp1").set("EOS", "IdealGas");
    model.thermodynamics().feature("pp1").set("VapDiffusivity", "Automatic");
    model.thermodynamics().feature("pp1").set("VLSurfaceTension", "Ideal");
    model.thermodynamics().feature("pp1").set("VapThermalConductivity", "KineticTheory");
    model.thermodynamics().feature("pp1").set("VapViscosity", "Brokaw");
    model.thermodynamics().feature("pp1").set("LiqDiffusivity", "WesselinghKrishna");
    model.thermodynamics().feature("pp1").set("LiqDiffusivityAtInfDilution", "Automatic");
    model.thermodynamics().feature("pp1").set("LLSurfaceTension", "None");
    model.thermodynamics().feature("pp1").set("LiqThermalConductivity", "Ideal");
    model.thermodynamics().feature("pp1").set("LiqViscosity", "LogarithmicMassMixing");
    model.thermodynamics().feature("pp1").set("LiqVolume", "IdealMixing");
    model.thermodynamics().feature("pp1").set("PoyntingFactor", "off");
    model.thermodynamics().feature("pp1")
         .set("property", new String[]{"Automatic", "Ideal", "KineticTheory", "Brokaw", "WesselinghKrishna", "Automatic", "None", "Ideal", "LogarithmicMassMixing", "IdealMixing", 
         "off"});
    model.thermodynamics().feature("pp1").storePersistenceData();
    model.thermodynamics().feature("pp1").set("WarningState", false);
    model.thermodynamics().feature("pp1").set("Warning", new String[]{""});

//    When modeling a fixed composition mixture, it is convenient to use a material. The reason is that the default behavior in physics interfaces is to use properties from the domain material. Use the <l>Thermodynamic System</l> to automatically define a <l>Material</l> node for the properties of the mixture.
//    Right-click Global Definitions > Thermodynamics > Vapor–Liquid System 1 (pp1) and choose Generate Material.
//    From the list, select Liquid.
//    Click Next in the window toolbar.
//    Notice that both species are already added to the Selected species list.
//    Find the Material composition subsection.
//    Click the Mass fraction button.
//    Keep the default composition in the Material composition subsection. The composition will be redefined in the generated Material.
//    Click Next in the window toolbar.
//    Use the default properties. The diffusion coefficients are not needed since a constant composition mixture is studied.
//    Click Next in the window toolbar.
//    Add the material to <l>Component 1</l>. Also keep the <l>Function type</l> set to <l>Thermodynamics</l>. This means that material properties will directly use functions defined by the <l>Vapor-Liquid System</l>.
//    Click Finish in the window toolbar.

    model.thermodynamics().feature("pp1").feature().create("singlephase1", "OnePhaseProperty");
    model.thermodynamics().feature("pp1").feature("singlephase1").label("Density 1");
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("funcname", "Density_ethylene_glycol_water_Liquid11");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("property", "Density");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("propertydescr", "Density");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("unit", "kg/m^3");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("prop_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("compounds", new String[]{"ethylene glycol", "water"});
    model.thermodynamics().feature("pp1").feature("singlephase1").set("phase", "Liquid");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("comp_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("include_derivatives", "yes");
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("args", new String[][]{{"temperature", "K", "Temperature"}, 
         {"pressure", "Pa", "Pressure"}, 
         {"massfraction_ethylene_glycol", "1", "Mass fraction ethylene glycol"}, 
         {"massfraction_water", "1", "Mass fraction water"}});
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("plotargs", new String[][]{{"temperature", "298.15", "373.15"}, 
         {"pressure", "101325", "101325"}, 
         {"massfraction_ethylene_glycol", "0.5", "0.5"}, 
         {"massfraction_water", "0.5", "0.5"}});
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("derivatives", new String[]{"Density_ethylene_glycol_water_Liquid11_Dtemperature", "Density_ethylene_glycol_water_Liquid11_Dpressure", "Density_ethylene_glycol_water_Liquid11_Dmassfraction_ethylene_glycol", "Density_ethylene_glycol_water_Liquid11_Dmassfraction_water"});
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("SecondDerivatives", new String[]{"Density_ethylene_glycol_water_Liquid11_Dtemperature_Dtemperature", "Density_ethylene_glycol_water_Liquid11_Dtemperature_Dpressure", "Density_ethylene_glycol_water_Liquid11_Dpressure_Dpressure"});
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("SecondDerivativeIndices", new String[]{"0", "0", "0", "0", "1", "1", "1", "1", "2"});
    model.thermodynamics().feature("pp1").feature().create("singlephase2", "OnePhaseProperty");
    model.thermodynamics().feature("pp1").feature("singlephase2").label("Heat capacity (Cp) 1");
    model.thermodynamics().feature("pp1").feature("singlephase2")
         .set("funcname", "HeatCapacityCp_ethylene_glycol_water_Liquid12");
    model.thermodynamics().feature("pp1").feature("singlephase2").set("property", "HeatCapacityCp");
    model.thermodynamics().feature("pp1").feature("singlephase2").set("propertydescr", "Heat capacity (Cp)");
    model.thermodynamics().feature("pp1").feature("singlephase2").set("unit", "J/kg/K");
    model.thermodynamics().feature("pp1").feature("singlephase2").set("prop_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase2")
         .set("compounds", new String[]{"ethylene glycol", "water"});
    model.thermodynamics().feature("pp1").feature("singlephase2").set("phase", "Liquid");
    model.thermodynamics().feature("pp1").feature("singlephase2").set("comp_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase2").set("include_derivatives", "yes");
    model.thermodynamics().feature("pp1").feature("singlephase2")
         .set("args", new String[][]{{"temperature", "K", "Temperature"}, 
         {"pressure", "Pa", "Pressure"}, 
         {"massfraction_ethylene_glycol", "1", "Mass fraction ethylene glycol"}, 
         {"massfraction_water", "1", "Mass fraction water"}});
    model.thermodynamics().feature("pp1").feature("singlephase2")
         .set("plotargs", new String[][]{{"temperature", "298.15", "373.15"}, 
         {"pressure", "101325", "101325"}, 
         {"massfraction_ethylene_glycol", "0.5", "0.5"}, 
         {"massfraction_water", "0.5", "0.5"}});
    model.thermodynamics().feature("pp1").feature("singlephase2")
         .set("derivatives", new String[]{"HeatCapacityCp_ethylene_glycol_water_Liquid12_Dtemperature", "HeatCapacityCp_ethylene_glycol_water_Liquid12_Dpressure", "HeatCapacityCp_ethylene_glycol_water_Liquid12_Dmassfraction_ethylene_glycol", "HeatCapacityCp_ethylene_glycol_water_Liquid12_Dmassfraction_water"});
    model.thermodynamics().feature("pp1").feature("singlephase2").set("SecondDerivatives", new String[]{});
    model.thermodynamics().feature("pp1").feature("singlephase2").set("SecondDerivativeIndices", new String[]{});
    model.thermodynamics().feature("pp1").feature().create("singlephase3", "OnePhaseProperty");
    model.thermodynamics().feature("pp1").feature("singlephase3").label("Thermal conductivity 1");
    model.thermodynamics().feature("pp1").feature("singlephase3")
         .set("funcname", "ThermalConductivity_ethylene_glycol_water_Liquid13");
    model.thermodynamics().feature("pp1").feature("singlephase3").set("property", "ThermalConductivity");
    model.thermodynamics().feature("pp1").feature("singlephase3").set("propertydescr", "Thermal conductivity");
    model.thermodynamics().feature("pp1").feature("singlephase3").set("unit", "W/m/K");
    model.thermodynamics().feature("pp1").feature("singlephase3").set("prop_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase3")
         .set("compounds", new String[]{"ethylene glycol", "water"});
    model.thermodynamics().feature("pp1").feature("singlephase3").set("phase", "Liquid");
    model.thermodynamics().feature("pp1").feature("singlephase3").set("comp_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase3").set("include_derivatives", "yes");
    model.thermodynamics().feature("pp1").feature("singlephase3")
         .set("args", new String[][]{{"temperature", "K", "Temperature"}, 
         {"pressure", "Pa", "Pressure"}, 
         {"massfraction_ethylene_glycol", "1", "Mass fraction ethylene glycol"}, 
         {"massfraction_water", "1", "Mass fraction water"}});
    model.thermodynamics().feature("pp1").feature("singlephase3")
         .set("plotargs", new String[][]{{"temperature", "298.15", "373.15"}, 
         {"pressure", "101325", "101325"}, 
         {"massfraction_ethylene_glycol", "0.5", "0.5"}, 
         {"massfraction_water", "0.5", "0.5"}});
    model.thermodynamics().feature("pp1").feature("singlephase3")
         .set("derivatives", new String[]{"ThermalConductivity_ethylene_glycol_water_Liquid13_Dtemperature", "ThermalConductivity_ethylene_glycol_water_Liquid13_Dpressure", "ThermalConductivity_ethylene_glycol_water_Liquid13_Dmassfraction_ethylene_glycol", "ThermalConductivity_ethylene_glycol_water_Liquid13_Dmassfraction_water"});
    model.thermodynamics().feature("pp1").feature("singlephase3").set("SecondDerivatives", new String[]{});
    model.thermodynamics().feature("pp1").feature("singlephase3").set("SecondDerivativeIndices", new String[]{});
    model.thermodynamics().feature("pp1").feature().create("singlephase4", "OnePhaseProperty");
    model.thermodynamics().feature("pp1").feature("singlephase4").label("Viscosity 1");
    model.thermodynamics().feature("pp1").feature("singlephase4")
         .set("funcname", "Viscosity_ethylene_glycol_water_Liquid14");
    model.thermodynamics().feature("pp1").feature("singlephase4").set("property", "Viscosity");
    model.thermodynamics().feature("pp1").feature("singlephase4").set("propertydescr", "Viscosity");
    model.thermodynamics().feature("pp1").feature("singlephase4").set("unit", "Pa*s");
    model.thermodynamics().feature("pp1").feature("singlephase4").set("prop_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase4")
         .set("compounds", new String[]{"ethylene glycol", "water"});
    model.thermodynamics().feature("pp1").feature("singlephase4").set("phase", "Liquid");
    model.thermodynamics().feature("pp1").feature("singlephase4").set("comp_basis", "mass");
    model.thermodynamics().feature("pp1").feature("singlephase4").set("include_derivatives", "yes");
    model.thermodynamics().feature("pp1").feature("singlephase4")
         .set("args", new String[][]{{"temperature", "K", "Temperature"}, 
         {"pressure", "Pa", "Pressure"}, 
         {"massfraction_ethylene_glycol", "1", "Mass fraction ethylene glycol"}, 
         {"massfraction_water", "1", "Mass fraction water"}});
    model.thermodynamics().feature("pp1").feature("singlephase4")
         .set("plotargs", new String[][]{{"temperature", "298.15", "373.15"}, 
         {"pressure", "101325", "101325"}, 
         {"massfraction_ethylene_glycol", "0.5", "0.5"}, 
         {"massfraction_water", "0.5", "0.5"}});
    model.thermodynamics().feature("pp1").feature("singlephase4")
         .set("derivatives", new String[]{"Viscosity_ethylene_glycol_water_Liquid14_Dtemperature", "Viscosity_ethylene_glycol_water_Liquid14_Dpressure", "Viscosity_ethylene_glycol_water_Liquid14_Dmassfraction_ethylene_glycol", "Viscosity_ethylene_glycol_water_Liquid14_Dmassfraction_water"});
    model.thermodynamics().feature("pp1").feature("singlephase4").set("SecondDerivatives", new String[]{});
    model.thermodynamics().feature("pp1").feature("singlephase4").set("SecondDerivativeIndices", new String[]{});
    model.thermodynamics().feature("pp1").feature("singlephase1").tag("mat_singlephase1");
    model.thermodynamics().feature("pp1").feature("mat_singlephase1").set("funcname", "Densitypp1");
    model.thermodynamics().feature("pp1").feature("singlephase2").tag("mat_singlephase2");
    model.thermodynamics().feature("pp1").feature("mat_singlephase2").set("funcname", "HeatCapacityCppp1");
    model.thermodynamics().feature("pp1").feature("singlephase3").tag("mat_singlephase3");
    model.thermodynamics().feature("pp1").feature("mat_singlephase3").set("funcname", "ThermalConductivitypp1");
    model.thermodynamics().feature("pp1").feature("singlephase4").tag("mat_singlephase4");
    model.thermodynamics().feature("pp1").feature("mat_singlephase4").set("funcname", "Viscositypp1");
    model.thermodynamics()
         .createMaterial("comp1", "pp1", "Liquid", new String[]{"ethylene glycol", "water"}, new String[]{"0.5", "0.5"}, new String[]{}, new String[][]{{"density", "Densitypp1"}, {"heatcapacitycp", "HeatCapacityCppp1"}, {"thermalconductivity", "ThermalConductivitypp1"}, {"viscosity", "Viscositypp1"}}, "Thermodynamics", new String[][]{{"8", "273", "373", "20", "101325", "201325", "15"}, 
         {"72", "273", "373", "20", "101325", "201325", "15"}, 
         {"60", "273", "373", "20", "101325", "201325", "15"}, 
         {"64", "273", "373", "20", "101325", "201325", "15"}}, new String[]{"mass", "mass"});

//    Load the needed parameters from a file. Alternatively, you could have created the parameters in the Parameter window directly.
//    In the Model Builder window, under Global Definitions, click Parameters 1.
//    In the Settings window for Parameters, locate the Parameters section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file engine_coolant_properties_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("w_EG", "0.527", "Mass fraction, ethylene glycol");
    model.param().set("w_W", "1-w_EG", "Mass fraction, water");
    model.param().set("Vel", "1.0[m/s]", "Pipe inlet velocity");
    model.param().set("r_p", "1.5[cm]", "Pipe radius");
    model.param().set("l_p", "20[cm]", "Pipe length");
    model.param().set("r_c", "10[cm]", "Chamber radius");
    model.param().set("l_c", "10[cm]", "Chamber length");
    model.param().set("zpos_c", "l_p/4", "Chamber position along the pipe");
    model.param().set("r_s1", "3[cm]", "Solid part 1, radius");
    model.param().set("l_s1", "0.5[cm]", "Solid part 1, length");
    model.param().set("r_s2", "0.35[cm]", "Solid part 2, radius");
    model.param().set("l_s2", "l_p-zpos_s", "Solid part 2, length");
    model.param().set("zpos_s", "zpos_c+0.3*l_c", "Solid parts position along the pipe");
    model.param().set("Tc", "353.15[K]", "Coolant temperature");
    model.param().set("pRef", "2[atm]", "Coolant pressure");
    model.param().set("n", "0", "Phase fraction");
    model.param().set("P0", "50[kW]", "Combustion heat flux");

//    Now that we have defined our Thermodynamic System and used that to generate a Material, it is time to build the geometry for the axially symmetric engine coolant test apparatus.
//    In the Model Builder window, expand the Component 1 (comp1) > Geometry 1 node.
//    Right-click Geometry 1 and choose 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 r_p.

    model.component("comp1").geom("geom1").feature("r1").set("size", new String[]{"r_p", "1"});

//    In the Height text field, type l_p.

    model.component("comp1").geom("geom1").feature("r1").set("size", new String[]{"r_p", "l_p"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("r1");

//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r2", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type r_c.

    model.component("comp1").geom("geom1").feature("r2").set("size", new String[]{"r_c", "1"});

//    In the Height text field, type l_c.

    model.component("comp1").geom("geom1").feature("r2").set("size", new String[]{"r_c", "l_c"});

//    Locate the Position section.
//    In the z text field, type zpos_c.

    model.component("comp1").geom("geom1").feature("r2").set("pos", new String[]{"0", "zpos_c"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("r2");

//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r3", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type r_s1.

    model.component("comp1").geom("geom1").feature("r3").set("size", new String[]{"r_s1", "1"});

//    In the Height text field, type l_s1.

    model.component("comp1").geom("geom1").feature("r3").set("size", new String[]{"r_s1", "l_s1"});

//    Locate the Position section.
//    In the z text field, type zpos_s.

    model.component("comp1").geom("geom1").feature("r3").set("pos", new String[]{"0", "zpos_s"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("r3");

//    In the Geometry toolbar, click Rectangle.

    model.component("comp1").geom("geom1").create("r4", "Rectangle");

//    In the Settings window for Rectangle, locate the Size and Shape section.
//    In the Width text field, type r_s2.

    model.component("comp1").geom("geom1").feature("r4").set("size", new String[]{"r_s2", "1"});

//    In the Height text field, type l_s2.

    model.component("comp1").geom("geom1").feature("r4").set("size", new String[]{"r_s2", "l_s2"});

//    Locate the Position section.
//    In the z text field, type zpos_s.

    model.component("comp1").geom("geom1").feature("r4").set("pos", new String[]{"0", "zpos_s"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("r4");

//    In the Geometry toolbar, click Booleans and Partitions and choose Union.

    model.component("comp1").geom("geom1").create("uni1", "Union");

//    Select the objects r3, r4.

    model.component("comp1").geom("geom1").feature("uni1").selection("input").set("r3", "r4");

//    In the Settings window for Union, locate the Union section.
//    Clear the Keep interior boundaries checkbox.

    model.component("comp1").geom("geom1").feature("uni1").set("intbnd", false);

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("uni1");

//    In the Geometry toolbar, click Booleans and Partitions and choose Union.

    model.component("comp1").geom("geom1").create("uni2", "Union");

//    Select the objects r1, r2.

    model.component("comp1").geom("geom1").feature("uni2").selection("input").set("r1", "r2");

//    In the Settings window for Union, locate the Union section.
//    Clear the Keep interior boundaries checkbox.

    model.component("comp1").geom("geom1").feature("uni2").set("intbnd", false);

//    Click Build Selected.

    model.component("comp1").geom("geom1").run("uni2");

//    In the Geometry toolbar, click Fillet.

    model.component("comp1").geom("geom1").create("fil1", "Fillet");

//    On the object uni1, select Point 5.

    model.component("comp1").geom("geom1").feature("fil1").selection("point").set("uni1", 5);
    model.component("comp1").geom("geom1").feature("fil1").selection("point").set("uni2", 6, 7, 9, 10);

//    On the object uni2, select Points 6, 7, 9, 10.
//    In the Settings window for Fillet, locate the Radius section.
//    In the Radius text field, type 0.3[cm].

    model.component("comp1").geom("geom1").feature("fil1").set("radius", "0.3[cm]");

//    Click Build All Objects.

    model.component("comp1").geom("geom1").runPre("fin");

//    Now, compute and plot the properties of the glycol-water coolant as defined by the <l>Thermodynamics</l> functions.
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Study 1: Mixture properties parameterization in the Label text field.

    model.study("std1").label("Study 1: Mixture properties parameterization");

//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std1").setGenPlots(false);

//    Start this investigation by performing an Auxiliary sweep study, where you study the effect of varying mass fraction of ethylene, and varying coolant temperature.
//    In the Model Builder window, under Study 1: Mixture properties parameterization, click Step 1: Stationary.
//    In the Settings window for Stationary, click to expand the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std1").feature("stat").set("useparam", true);

//    Click Add.

    model.study("std1").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "", 0);
    model.study("std1").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "", 0);
    model.study("std1").feature("stat").setIndex("punit", "", 0);

//     twice.

    model.study("std1").feature("stat").setIndex("pname", "w_W", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "", 1);
    model.study("std1").feature("stat").setIndex("punit", "", 1);
    model.study("std1").feature("stat").setIndex("pname", "w_W", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "", 1);
    model.study("std1").feature("stat").setIndex("punit", "", 1);

//    In the table, enter the following settings:

    model.study("std1").feature("stat").setIndex("plistarr", "0 0.527 1", 0);
    model.study("std1").feature("stat").setIndex("pname", "Tc", 1);
    model.study("std1").feature("stat").setIndex("plistarr", "range(273,10,473)", 1);

//    From the Sweep type list, select All combinations.

    model.study("std1").feature("stat").set("sweeptype", "filled");

//    During this first Auxiliary sweep study there is no need to solve for turbulent flow and heat transfer. Change the settings to omit solving for these interfaces.

    model.study("std1").feature("stat").setSolveFor("/physics/spf", false);

//    Locate the Physics and Variables Selection section.

    model.study("std1").feature("stat").setSolveFor("/physics/ht", false);
    model.study("std1").feature("stat").setSolveFor("/multiphysics/nitf1", false);

//    In the Solve for column of the table, under Component 1 (comp1), clear the checkboxes for Turbulent Flow, k-ε (spf), Heat Transfer in Fluids (ht).
//    In the Solve for column of the table, under Component 1 (comp1) > Multiphysics, clear the checkbox for Nonisothermal Flow 1 (nitf1).
//    The parametric solver has now been set up to compute function values for pure water, a 50 volume percent mixture of ethylene glycol and water, and pure ethylene glycol. Furthermore, the solver will compute function values for a temperature range from 273 K to 473 K.
//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol("sol1").runAll();

//    Now, inspect the results from the study by creating a plot group and plot the results. Start with the density.
//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg1", "PlotGroup1D");
    model.result("pg1").run();

//    In the Settings window for 1D Plot Group, type Density in the Label text field.

    model.result("pg1").label("Density");

//    Click to expand the Title section.
//    From the Title type list, select None.

    model.result("pg1").set("titletype", "none");

//    In the Density toolbar, click Global.

    model.result("pg1").create("glob1", "Global");
    model.result("pg1").feature("glob1").set("markerpos", "datapoints");
    model.result("pg1").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Global definitions > Functions > Densitypp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water) - Density 1.

    model.result("pg1").feature("glob1")
         .set("expr", new String[]{"Densitypp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water)"});
    model.result("pg1").feature("glob1").set("descr", new String[]{"Density 1"});
    model.result("pg1").feature("glob1").set("unit", new String[]{""});

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg1").feature("glob1").setIndex("expr", "Densitypp1(Tc,pRef,w_EG,w_W)", 0);
    model.result("pg1").feature("glob1").setIndex("unit", "", 0);
    model.result("pg1").feature("glob1").setIndex("descr", "", 0);

//    Click to expand the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg1").feature("glob1").set("linewidth", 2);

//    Click to expand the Legends section.
//    Find the Include subsection.
//    Clear the Description checkbox.

    model.result("pg1").feature("glob1").set("autodescr", false);

//    Note: The function named <c>Densitypp1</c>, can be found in the <l>Model Builder</l> window, under <l>Global Definitions</l> &gt; <l>Thermodynamics</l>. Click the mixture density function, labeled <l>Density 1</l>, and you will find the Function name in the <l>Settings</l> window. The function was created by the Thermodynamic System and can be used in any physics interface.
//    Return to the plot group to improve the plot settings.

    model.result("pg1").run();

//    In the Model Builder window, click Density.
//    In the Settings window for 1D Plot Group, locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg1").set("xlabelactive", true);

//    Select the y-axis label checkbox.

    model.result("pg1").set("ylabelactive", true);

//    In the x-axis label text field, type Temperature (K).

    model.result("pg1").set("xlabel", "Temperature (K)");

//    In the y-axis label text field, type Density (kg/m<sup>3</sup>).

    model.result("pg1").set("ylabel", "Density (kg/m<sup>3</sup>)");

//    In the Density toolbar, click Plot.

    model.result("pg1").run();

//    The resulting plot shows the coolant density for the three compositions. Perform the same steps to complete the plots for viscosity, thermal conductivity and heat capacity.
//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg2", "PlotGroup1D");
    model.result("pg2").run();

//    In the Settings window for 1D Plot Group, type Viscosity in the Label text field.

    model.result("pg2").label("Viscosity");

//    Locate the Title section.
//    From the Title type list, select None.

    model.result("pg2").set("titletype", "none");

//    In the Viscosity toolbar, click Global.

    model.result("pg2").create("glob1", "Global");
    model.result("pg2").feature("glob1").set("markerpos", "datapoints");
    model.result("pg2").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Global definitions > Functions > Viscositypp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water) - Viscosity 1.

    model.result("pg2").feature("glob1")
         .set("expr", new String[]{"Viscositypp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water)"});
    model.result("pg2").feature("glob1").set("descr", new String[]{"Viscosity 1"});
    model.result("pg2").feature("glob1").set("unit", new String[]{""});

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg2").feature("glob1").setIndex("expr", "Viscositypp1(Tc,pRef,w_EG,w_W)", 0);
    model.result("pg2").feature("glob1").setIndex("unit", "", 0);
    model.result("pg2").feature("glob1").setIndex("descr", "", 0);

//    Locate the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg2").feature("glob1").set("linewidth", 2);

//    Locate the Legends section.
//    Find the Include subsection.
//    Clear the Description checkbox.

    return model;
  }

  public static Model run2(Model model) {

    model.result("pg2").feature("glob1").set("autodescr", false);
    model.result("pg2").run();

//    In the Model Builder window, click Viscosity.
//    In the Settings window for 1D Plot Group, locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg2").set("xlabelactive", true);

//    Select the y-axis label checkbox.

    model.result("pg2").set("ylabelactive", true);

//    In the x-axis label text field, type Temperature (K).

    model.result("pg2").set("xlabel", "Temperature (K)");

//    In the y-axis label text field, type Viscosity (Pa*s).

    model.result("pg2").set("ylabel", "Viscosity (Pa*s)");

//    In the Viscosity toolbar, click Plot.

    model.result("pg2").run();

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg3", "PlotGroup1D");
    model.result("pg3").run();

//    In the Settings window for 1D Plot Group, type Thermal Conductivity in the Label text field.

    model.result("pg3").label("Thermal Conductivity");

//    Locate the Title section.
//    From the Title type list, select None.

    model.result("pg3").set("titletype", "none");

//    In the Thermal Conductivity toolbar, click Global.

    model.result("pg3").create("glob1", "Global");
    model.result("pg3").feature("glob1").set("markerpos", "datapoints");
    model.result("pg3").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Global definitions > Functions > ThermalConductivitypp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water) - Thermal conductivity 1.

    model.result("pg3").feature("glob1")
         .set("expr", new String[]{"ThermalConductivitypp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water)"});
    model.result("pg3").feature("glob1").set("descr", new String[]{"Thermal conductivity 1"});
    model.result("pg3").feature("glob1").set("unit", new String[]{""});

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg3").feature("glob1").setIndex("expr", "ThermalConductivitypp1(Tc,pRef,w_EG,w_W)", 0);
    model.result("pg3").feature("glob1").setIndex("unit", "", 0);
    model.result("pg3").feature("glob1").setIndex("descr", "", 0);

//    Locate the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg3").feature("glob1").set("linewidth", 2);

//    Locate the Legends section.
//    Find the Include subsection.
//    Clear the Description checkbox.

    model.result("pg3").feature("glob1").set("autodescr", false);
    model.result("pg3").run();

//    In the Model Builder window, click Thermal Conductivity.
//    In the Settings window for 1D Plot Group, locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg3").set("xlabelactive", true);

//    In the associated text field, type Temperature (K).

    model.result("pg3").set("xlabel", "Temperature (K)");

//    Select the y-axis label checkbox.

    model.result("pg3").set("ylabelactive", true);

//    In the associated text field, type Thermal conductivity (W/(m*K)).

    model.result("pg3").set("ylabel", "Thermal conductivity (W/(m*K))");

//    Locate the Legend section.
//    From the Position list, select Middle right.

    model.result("pg3").set("legendpos", "middleright");

//    In the Thermal Conductivity toolbar, click Plot.

    model.result("pg3").run();

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg4", "PlotGroup1D");
    model.result("pg4").run();

//    In the Settings window for 1D Plot Group, type Heat Capacity in the Label text field.

    model.result("pg4").label("Heat Capacity");

//    Locate the Title section.
//    From the Title type list, select None.

    model.result("pg4").set("titletype", "none");

//    In the Heat Capacity toolbar, click Global.

    model.result("pg4").create("glob1", "Global");
    model.result("pg4").feature("glob1").set("markerpos", "datapoints");
    model.result("pg4").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Global definitions > Functions > HeatCapacityCppp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water) - Heat capacity (Cp) 1.

    model.result("pg4").feature("glob1")
         .set("expr", new String[]{"HeatCapacityCppp1(temperature, pressure, massfraction_ethylene_glycol, massfraction_water)"});
    model.result("pg4").feature("glob1").set("descr", new String[]{"Heat capacity (Cp) 1"});
    model.result("pg4").feature("glob1").set("unit", new String[]{""});

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg4").feature("glob1").setIndex("expr", "HeatCapacityCppp1(Tc,pRef,w_EG,w_W)", 0);
    model.result("pg4").feature("glob1").setIndex("unit", "", 0);
    model.result("pg4").feature("glob1").setIndex("descr", "", 0);

//    Locate the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg4").feature("glob1").set("linewidth", 2);

//    Locate the Legends section.
//    Find the Include subsection.
//    Clear the Description checkbox.

    model.result("pg4").feature("glob1").set("autodescr", false);
    model.result("pg4").run();

//    In the Model Builder window, click Heat Capacity.
//    In the Settings window for 1D Plot Group, locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg4").set("xlabelactive", true);

//    In the associated text field, type Temperature (K).

    model.result("pg4").set("xlabel", "Temperature (K)");

//    Select the y-axis label checkbox.

    model.result("pg4").set("ylabelactive", true);

//    In the associated text field, type Heat capacity (J/(kg*K)).

    model.result("pg4").set("ylabel", "Heat capacity (J/(kg*K))");

//    Locate the Legend section.
//    From the Position list, select Upper left.

    model.result("pg4").set("legendpos", "upperleft");

//    In the Heat Capacity toolbar, click Plot.

    model.result("pg4").run();

//    Now, use the thermodynamic system to define an equilibrium function. This will be used to visualize the phase envelope of the coolant mixture.
//    In the Model Builder window, right-click Global Definitions > Thermodynamics > Vapor–Liquid System 1 (pp1) and choose Equilibrium Calculation.
//    Click Add All.
//    Click Next in the window toolbar.
//    From the Amount base unit list, select mol.
//    Find the Equilibrium conditions subsection.
//    From the First condition list, select Pressure.
//    From the Second condition list, select Phase fraction.
//    Click Next in the window toolbar.

    model.thermodynamics().feature("pp1").feature().create("flashcalc1", "FlashCalculationProperty");
    model.thermodynamics().feature("pp1").feature().remove("flashcalc1");

//    Click Finish in the window toolbar.

    model.thermodynamics().feature("pp1").feature().create("flashcalc1", "FlashCalculationProperty");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("funcname", "flashcalc1");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("property", "FlashCalculationProperty");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("propertydescr", "Equilibrium calculation");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("dvars", new String[]{"0", "0", "0", "0"});
    model.thermodynamics().feature("pp1").feature("flashcalc1")
         .set("compounds", new String[]{"ethylene glycol", "water"});
    model.thermodynamics().feature("pp1").feature("flashcalc1")
         .set("functions", new String[][]{{"Flash1_1_PhaseExist_Vapor", "1", "Presence of Vapor phase"}, 
         {"Flash1_1_PhaseExist_Liquid", "1", "Presence of Liquid phase"}, 
         {"Flash1_1_Temperature", "K", "Temperature"}, 
         {"Flash1_1_PhaseAmount_Vapor", "mol", "Amount in Vapor phase"}, 
         {"Flash1_1_PhaseAmount_Liquid", "mol", "Amount in Liquid phase"}, 
         {"Flash1_1_PhaseComposition_Vapor_ethylene_glycol", "mol/mol", "Fraction of ethylene glycol in Vapor phase"}, 
         {"Flash1_1_PhaseComposition_Vapor_water", "mol/mol", "Fraction of water in Vapor phase"}, 
         {"Flash1_1_PhaseComposition_Liquid_ethylene_glycol", "mol/mol", "Fraction of ethylene glycol in Liquid phase"}, 
         {"Flash1_1_PhaseComposition_Liquid_water", "mol/mol", "Fraction of water in Liquid phase"}});
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("cond1", new String[]{"pressure"});
    model.thermodynamics().feature("pp1").feature("flashcalc1")
         .set("cond2", new String[]{"phasefraction", "mole", "Vapor"});
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("prop_basis", "mole");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("inphase", "Flash1_1_PhaseExist");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("temperature", "Flash1_1_Temperature");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("pressure", "Flash1_1_Pressure");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("amounts", "Flash1_1_PhaseAmount");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("composition", "Flash1_1_PhaseComposition");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("soltype", "undefined");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("unit", "1");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("phases", new String[]{"Vapor", "Liquid"});
    model.thermodynamics().feature("pp1").feature("flashcalc1")
         .set("args", new String[][]{{"pressure", "Pa", "Pressure"}, 
         {"phasefraction", "mol/mol", "Vapor Mole fraction"}, 
         {"ethylene_glycol", "mol", "Amount ethylene glycol"}, 
         {"water", "mol", "Amount water"}});
    model.thermodynamics().feature("pp1").feature("flashcalc1")
         .set("plotargs", new String[][]{{"pressure", "101325", "101325"}, 
         {"phasefraction", "0.5", "0.5"}, 
         {"ethylene_glycol", "1", "1"}, 
         {"water", "1", "1"}});
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("derivatives", "");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("SecondDerivatives", "");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("SecondDerivativeIndices", "");
    model.thermodynamics().feature("pp1").feature("flashcalc1").set("plotfunction", "Flash1_1_PhaseExist_Vapor");
    model.thermodynamics().feature("pp1").set("WarningState", false);
    model.thermodynamics().feature("pp1").set("Warning", new String[]{""});

//    You can now create an Analytic function to plot the phase envelope. Create an Analytic function from the equilibrium function just defined. Analytic functions are convenient since they do not require the actual argument names in an expression when writing the function. Also, use the Analytic function to change the composition arguments from moles to mole fractions.
//    In the Home toolbar, click Functions and choose Global > Analytic.

    model.func().create("an1", "Analytic");

//    In the Settings window for Analytic, type Phase envelope in the Label text field.

    model.func("an1").label("Phase envelope");

//    In the Function name text field, type T_x_y.

    model.func("an1").set("funcname", "T_x_y");

//    Locate the Definition section.
//    In the Expression text field, type Flash1_1_Temperature(p,n,w_EG,w_W).

    model.func("an1").set("expr", "Flash1_1_Temperature(p,n,w_EG,w_W)");

//    In the Arguments text field, type p, n, w_EG, w_W.

    model.func("an1").set("args", "p, n, w_EG, w_W");

//    Remember to use the same order of the arguments as defined in the Equilibrium Calculation node.
//    Locate the Units section.
//    In the table, enter the following settings:

    model.func("an1").setIndex("argunit", "Pa", 0);
    model.func("an1").setIndex("argunit", 1, 1);
    model.func("an1").setIndex("argunit", "mol/mol", 2);
    model.func("an1").setIndex("argunit", "mol/mol", 3);

//    In the Function text field, type K.

    model.func("an1").set("fununit", "K");

//    Note: The expression <c>Flash1_1_Temperature</c> and what arguments to use can be found in the <l>Model Builder</l> window, under <l>Global Definitions</l> &gt; <l>Thermodynamics</l> &gt; <l>Vapor-Liquid System 1 (pp1)</l> &gt; <l>Mixture</l>. Under <l>Mixture</l>, click <l>Equilibrium Calculation</l>. In the <l>Settings</l> window, locate the <l>Functions</l> subsection, as well as the <l>Arguments</l> subsection, both in the <l>Definition</l> section.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Add a Study to compute the phase envelope for the mixture, using the defined analytic function.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Stationary.
//    Right-click and choose Add Study.

    model.study().create("std2");
    model.study("std2").create("stat", "Stationary");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    Add settings to perform an Auxiliary sweep study, where we vary mass fraction of ethylene glycol, phase fraction, and coolant pressure.
//    In the Settings window for Stationary, locate the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std2").feature("stat").set("useparam", true);

//    Click Add.

    model.study("std2").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std2").feature("stat").setIndex("plistarr", "", 0);
    model.study("std2").feature("stat").setIndex("punit", "", 0);
    model.study("std2").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std2").feature("stat").setIndex("plistarr", "", 0);
    model.study("std2").feature("stat").setIndex("punit", "", 0);

//     three times.

    model.study("std2").feature("stat").setIndex("pname", "w_W", 1);
    model.study("std2").feature("stat").setIndex("plistarr", "", 1);
    model.study("std2").feature("stat").setIndex("punit", "", 1);
    model.study("std2").feature("stat").setIndex("pname", "w_W", 1);
    model.study("std2").feature("stat").setIndex("plistarr", "", 1);
    model.study("std2").feature("stat").setIndex("punit", "", 1);
    model.study("std2").feature("stat").setIndex("pname", "Vel", 2);
    model.study("std2").feature("stat").setIndex("plistarr", "", 2);
    model.study("std2").feature("stat").setIndex("punit", "m/s", 2);
    model.study("std2").feature("stat").setIndex("pname", "Vel", 2);
    model.study("std2").feature("stat").setIndex("plistarr", "", 2);
    model.study("std2").feature("stat").setIndex("punit", "m/s", 2);

//    In the table, enter the following settings:

    model.study("std2").feature("stat").setIndex("plistarr", "range(0,0.01,1)", 0);
    model.study("std2").feature("stat").setIndex("pname", "n", 1);
    model.study("std2").feature("stat").setIndex("plistarr", "0 1", 1);
    model.study("std2").feature("stat").setIndex("pname", "pRef", 2);
    model.study("std2").feature("stat").setIndex("plistarr", "1[atm] 2[atm]", 2);
    model.study("std2").feature("stat").setIndex("punit", "Pa", 2);

//    From the Sweep type list, select All combinations.

    model.study("std2").feature("stat").set("sweeptype", "filled");

//    In the Model Builder window, click Study 2.
//    In the Settings window for Study, type Study 2: Phase envelope parameterization in the Label text field.

    model.study("std2").label("Study 2: Phase envelope parameterization");

//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std2").setGenPlots(false);
    model.study("std2").feature("stat").setSolveFor("/physics/spf", false);

//    In the Model Builder window, click Step 1: Stationary.
//    In the Settings window for Stationary, locate the Physics and Variables Selection section.

    model.study("std2").feature("stat").setSolveFor("/physics/ht", false);
    model.study("std2").feature("stat").setSolveFor("/multiphysics/nitf1", false);

//    In the Solve for column of the table, under Component 1 (comp1), clear the checkboxes for Turbulent Flow, k-ε (spf), Heat Transfer in Fluids (ht).
//    In the Solve for column of the table, under Component 1 (comp1) > Multiphysics, clear the checkbox for Nonisothermal Flow 1 (nitf1).
//    In the Study toolbar, click Compute.

    model.study("std2").createAutoSequences("all");

    model.sol("sol2").runAll();

//    Plot the phase envelope, for the two pressures used, as a function of the mole fraction of ethylene glycol.
//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg5", "PlotGroup1D");
    model.result("pg5").run();

//    In the Settings window for 1D Plot Group, locate the Data section.
//    From the Dataset list, select Study 2: Phase envelope parameterization/Solution 2 (sol2).

    model.result("pg5").set("data", "dset2");

//    Locate the Title section.
//    From the Title type list, select None.

    model.result("pg5").set("titletype", "none");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg5").set("xlabelactive", true);

//    In the associated text field, type Mole fraction ethylene glycol.

    model.result("pg5").set("xlabel", "Mole fraction ethylene glycol");

//    Select the y-axis label checkbox.

    model.result("pg5").set("ylabelactive", true);

//    In the associated text field, type Temperature (K).

    model.result("pg5").set("ylabel", "Temperature (K)");

//    In the 1D Plot Group 5 toolbar, click Global.

    model.result("pg5").create("glob1", "Global");
    model.result("pg5").feature("glob1").set("markerpos", "datapoints");
    model.result("pg5").feature("glob1").set("linewidth", "preference");

//    In the Settings window for Global, locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg5").feature("glob1").setIndex("expr", "T_x_y(pRef, n, w_EG, w_W)", 0);
    model.result("pg5").feature("glob1").setIndex("unit", "", 0);
    model.result("pg5").feature("glob1").setIndex("descr", "", 0);

//    Locate the x-Axis Data section.
//    From the Axis source data list, select w_EG.

    model.result("pg5").feature("glob1").set("xdatasolnumtype", "level3");

//    Locate the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg5").feature("glob1").set("linewidth", 2);

//    In the 1D Plot Group 5 toolbar, click Plot.

    model.result("pg5").run();
    model.result("pg5").run();

//    In the Model Builder window, click 1D Plot Group 5.
//    In the Settings window for 1D Plot Group, locate the Legend section.
//    From the Position list, select Upper left.

    model.result("pg5").set("legendpos", "upperleft");

//    In the Label text field, type Phase Envelope.

    model.result("pg5").label("Phase Envelope");

//    Apply the material to the fluid domain. Also, use the defined parameters to specify the mixture composition. This makes it easy to vary the composition.
//    In the Model Builder window, expand the Component 1 (comp1) > Materials node, then click Liquid: ethylene glycol-water 1 (pp1mat1).
//    Select Domain 1.

    model.component("comp1").material("pp1mat1").selection().set(1);

//    In the Settings window for Material, locate the Material Contents section.
//    Find the Local properties subsection.
//    In the table, enter the following settings:

    model.component("comp1").material("pp1mat1").propertyGroup("def").set("xw1", new String[]{"w_EG"});
    model.component("comp1").material("pp1mat1").propertyGroup("def").set("xw2", new String[]{"w_W"});

//    Now apply boundary conditions.
//    In the Model Builder window, under Component 1 (comp1), click Turbulent Flow, k-ε (spf).
//    Select Domain 1.

    model.component("comp1").physics("spf").selection().set(1);

//    In the Physics toolbar, click Boundaries and choose Inlet.

    model.component("comp1").physics("spf").create("inl1", "InletBoundary", 1);

//    Select Boundary 2.

    model.component("comp1").physics("spf").feature("inl1").selection().set(2);

//    In the Settings window for Inlet, locate the Velocity section.
//    In the \[U_{\textrm{0}}\] text field, type Vel.

    model.component("comp1").physics("spf").feature("inl1").set("U0in", "Vel");

//    In the Physics toolbar, click Boundaries and choose Outlet.

    model.component("comp1").physics("spf").create("out1", "OutletBoundary", 1);

//    Select Boundary 11.

    model.component("comp1").physics("spf").feature("out1").selection().set(11);

//    In the Model Builder window, under Component 1 (comp1), click Heat Transfer in Fluids (ht).
//    In the Physics toolbar, click Boundaries and choose Inflow.

    model.component("comp1").physics("ht").create("ifl1", "Inflow", 1);

//    Select Boundary 2.

    model.component("comp1").physics("ht").feature("ifl1").selection().set(2);

//    In the Settings window for Inflow, locate the Upstream Properties section.
//    In the \[T_\textrm{ustr}\] text field, type Tc.

    model.component("comp1").physics("ht").feature("ifl1").set("Tustr", "Tc");

//    Select the Specify upstream absolute pressure checkbox.

    model.component("comp1").physics("ht").feature("ifl1").set("specifyUpstreamAbsolutePressure", true);

//    In the \[p_\textrm{ustr}\] text field, type pRef.

    model.component("comp1").physics("ht").feature("ifl1").set("pustr", "pRef");

//    In the Physics toolbar, click Boundaries and choose Outflow.

    model.component("comp1").physics("ht").create("ofl1", "ConvectiveOutflow", 1);

//    Select Boundary 11.

    model.component("comp1").physics("ht").feature("ofl1").selection().set(11);

//    In the Physics toolbar, click Boundaries and choose Heat Flux.

    model.component("comp1").physics("ht").create("hf1", "HeatFluxBoundary", 1);

//    Select Boundary 18.

    model.component("comp1").physics("ht").feature("hf1").selection().set(18);

//    In the Settings window for Heat Flux, locate the Heat Flux section.
//    From the Flux type list, select Heat rate.

    model.component("comp1").physics("ht").feature("hf1").set("HeatFluxType", "HeatRate");

//    In the \[P_0\] text field, type P0.

    model.component("comp1").physics("ht").feature("hf1").set("P0", "P0");

//    In the Physics toolbar, click Domains and choose Solid.

    model.component("comp1").physics("ht").create("solid1", "SolidHeatTransferModel", 2);

//    Select Domain 2.

    model.component("comp1").physics("ht").feature("solid1").selection().set(2);

//    Add material properties for the solid steel part from <l>Materials</l>.
//    In the Home toolbar, click Add Material to open the Add Material window.
//    In the tree, select Built-in > Structural steel.
//    Click Add to Component in the window toolbar.

    model.component("comp1").material().create("mat1", "Common");
    model.component("comp1").material("mat1").propertyGroup()
         .create("Enu", "Enu", "Young's modulus and Poisson's ratio");
    model.component("comp1").material("mat1").propertyGroup("Enu").func().create("int1", "Interpolation");
    model.component("comp1").material("mat1").propertyGroup("Enu").func().create("int2", "Interpolation");
    model.component("comp1").material("mat1").propertyGroup().create("Murnaghan", "Murnaghan", "Murnaghan");
    model.component("comp1").material("mat1").propertyGroup()
         .create("ElastoplasticModel", "ElastoplasticModel", "Elastoplastic material model");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").func()
         .create("int1", "Interpolation");
    model.component("comp1").material("mat1").propertyGroup().create("Ludwik", "Ludwik", "Ludwik");
    model.component("comp1").material("mat1").propertyGroup("Ludwik").func().create("int1", "Interpolation");
    model.component("comp1").material("mat1").propertyGroup().create("JohnsonCook", "JohnsonCook", "Johnson-Cook");
    model.component("comp1").material("mat1").propertyGroup().create("Swift", "Swift", "Swift");
    model.component("comp1").material("mat1").propertyGroup().create("Voce", "Voce", "Voce");
    model.component("comp1").material("mat1").propertyGroup("Voce").func().create("int1", "Interpolation");
    model.component("comp1").material("mat1").propertyGroup()
         .create("HockettSherby", "HockettSherby", "Hockett-Sherby");
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").func().create("int1", "Interpolation");
    model.component("comp1").material("mat1").propertyGroup()
         .create("ArmstrongFrederick", "ArmstrongFrederick", "Armstrong-Frederick");
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").func()
         .create("int1", "Interpolation");
    model.component("comp1").material("mat1").propertyGroup().create("Norton", "Norton", "Norton");
    model.component("comp1").material("mat1").propertyGroup()
         .create("Garofalo", "Garofalo", "Garofalo (hyperbolic sine)");
    model.component("comp1").material("mat1").propertyGroup()
         .create("ChabocheViscoplasticity", "ChabocheViscoplasticity", "Chaboche viscoplasticity");
    model.component("comp1").material("mat1").label("Structural steel");
    model.component("comp1").material("mat1").set("family", "custom");
    model.component("comp1").material("mat1")
         .set("customspecular", new double[]{0.7843137254901961, 0.7843137254901961, 0.7843137254901961});
    model.component("comp1").material("mat1").set("diffuse", "custom");
    model.component("comp1").material("mat1")
         .set("customdiffuse", new double[]{0.6666666666666666, 0.6666666666666666, 0.6666666666666666});
    model.component("comp1").material("mat1").set("ambient", "custom");
    model.component("comp1").material("mat1")
         .set("customambient", new double[]{0.6666666666666666, 0.6666666666666666, 0.6666666666666666});
    model.component("comp1").material("mat1").set("noise", true);
    model.component("comp1").material("mat1").set("fresnel", 0.9);
    model.component("comp1").material("mat1").set("roughness", 0.3);
    model.component("comp1").material("mat1").set("diffusewrap", 0);
    model.component("comp1").material("mat1").set("reflectance", 0);
    model.component("comp1").material("mat1").propertyGroup("def").set("lossfactor", "0.02");
    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("heatcapacity", "475[J/(kg*K)]");
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("thermalconductivity", new String[]{"44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]", "0", "0", "0", "44.5[W/(m*K)]"});
    model.component("comp1").material("mat1").propertyGroup("def")
         .set("electricconductivity", new String[]{"4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]", "0", "0", "0", "4.032e6[S/m]"});
    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("thermalexpansioncoefficient", new String[]{"12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]", "0", "0", "0", "12.3e-6[1/K]"});
    model.component("comp1").material("mat1").propertyGroup("def").set("density", "7850[kg/m^3]");
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int1").set("funcname", "E");
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int1")
         .set("table", new String[][]{{"293.15", "200e9"}, {"793.15", "166.6e9"}});
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int1").set("extrap", "linear");
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int1").set("fununit", new String[]{"Pa"});
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int2").set("funcname", "nu");
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int2")
         .set("table", new String[][]{{"293.15", "0.30"}, {"793.15", "0.315"}});
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int2").set("extrap", "linear");
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int2").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat1").propertyGroup("Enu").func("int2").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("Enu").set("E", "E(T)");
    model.component("comp1").material("mat1").propertyGroup("Enu").set("nu", "nu(T)");
    model.component("comp1").material("mat1").propertyGroup("Enu").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("Murnaghan").set("l", "-3.0e11[Pa]");
    model.component("comp1").material("mat1").propertyGroup("Murnaghan").set("m", "-6.2e11[Pa]");
    model.component("comp1").material("mat1").propertyGroup("Murnaghan").set("n", "-7.2e11[Pa]");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").func("int1").set("funcname", "a");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").set("sigmags", "350[MPa]*a(T)");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").set("Et", "1.045[GPa]*a(T)");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").set("Ek", "1.045[GPa]*a(T)");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel")
         .set("sigmagh", "1.050[GPa]*epe*a(T)");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel")
         .set("Hillcoefficients", new String[]{"0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]", "0[m^2*s^4/kg^2]"});
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel")
         .set("ys", new String[]{"0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]", "0[N/m^2]"});
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("ElastoplasticModel").addInput("effectiveplasticstrain");
    model.component("comp1").material("mat1").propertyGroup("Ludwik").func("int1").set("funcname", "a");
    model.component("comp1").material("mat1").propertyGroup("Ludwik").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat1").propertyGroup("Ludwik").func("int1").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat1").propertyGroup("Ludwik").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("Ludwik").set("k_lud", "560[MPa]*a(T)");
    model.component("comp1").material("mat1").propertyGroup("Ludwik").set("n_lud", "0.61");
    model.component("comp1").material("mat1").propertyGroup("Ludwik").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("JohnsonCook").label("Johnson-Cook");
    model.component("comp1").material("mat1").propertyGroup("JohnsonCook").set("k_jcook", "560[MPa]");

    return model;
  }

  public static Model run3(Model model) {
    model.component("comp1").material("mat1").propertyGroup("JohnsonCook").set("n_jcook", "0.61");
    model.component("comp1").material("mat1").propertyGroup("JohnsonCook").set("C_jcook", "0.12");
    model.component("comp1").material("mat1").propertyGroup("JohnsonCook").set("epet0_jcook", "1[1/s]");
    model.component("comp1").material("mat1").propertyGroup("JohnsonCook").set("m_jcook", "0.6");
    model.component("comp1").material("mat1").propertyGroup("Swift").set("e0_swi", "0.021");
    model.component("comp1").material("mat1").propertyGroup("Swift").set("n_swi", "0.2");
    model.component("comp1").material("mat1").propertyGroup("Voce").func("int1").set("funcname", "a");
    model.component("comp1").material("mat1").propertyGroup("Voce").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat1").propertyGroup("Voce").func("int1").set("fununit", new String[]{"1"});
    model.component("comp1").material("mat1").propertyGroup("Voce").func("int1").set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("Voce").set("sigma_voc", "249[MPa]*a(T)");
    model.component("comp1").material("mat1").propertyGroup("Voce").set("beta_voc", "9.3");
    model.component("comp1").material("mat1").propertyGroup("Voce").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").label("Hockett-Sherby");
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").func("int1").set("funcname", "a");
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").set("sigma_hoc", "684[MPa]*a(T)");
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").set("m_hoc", "3.9");
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").set("n_hoc", "0.85");
    model.component("comp1").material("mat1").propertyGroup("HockettSherby").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").label("Armstrong-Frederick");
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").func("int1").set("funcname", "a");
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").func("int1")
         .set("table", new String[][]{{"600", "1"}, {"1100", "0.1"}, {"1643", "0"}});
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").func("int1")
         .set("fununit", new String[]{"1"});
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").func("int1")
         .set("argunit", new String[]{"K"});
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").set("Ck", "2.070[GPa]*a(T)");
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").set("gammak", "8.0");
    model.component("comp1").material("mat1").propertyGroup("ArmstrongFrederick").addInput("temperature");
    model.component("comp1").material("mat1").propertyGroup("Norton").set("A_nor", "1.2e-15[1/s]");
    model.component("comp1").material("mat1").propertyGroup("Norton").set("sigRef_nor", "1[MPa]");
    model.component("comp1").material("mat1").propertyGroup("Norton").set("n_nor", "4.5");
    model.component("comp1").material("mat1").propertyGroup("Garofalo").set("A_gar", "1e-6[1/s]");
    model.component("comp1").material("mat1").propertyGroup("Garofalo").set("sigRef_gar", "100[MPa]");
    model.component("comp1").material("mat1").propertyGroup("Garofalo").set("n_gar", "4.6");
    model.component("comp1").material("mat1").propertyGroup("ChabocheViscoplasticity").set("A_cha", "1[1/s]");
    model.component("comp1").material("mat1").propertyGroup("ChabocheViscoplasticity").set("sigRef_cha", "490[MPa]");
    model.component("comp1").material("mat1").propertyGroup("ChabocheViscoplasticity").set("n_cha", "9");

//    In the Home toolbar, click Add Material to close the Add Material window.
//    Select Domain 2.

    model.component("comp1").material("mat1").selection().set(2);

//    Now add a <l>Stationary</l> study to solve for the fluid flow and heat transfer in the test apparatus using pure water as the coolant.
//    Use two stationary study steps. The first step solves for the fluid flow only. This serves as initial conditions for the second step, which in turn solves for both fluid flow and heat transfer.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Stationary.
//    Find the Physics interfaces in study subsection.
//    In the table, enter the following settings:
//    Click Add Study in the window toolbar.

    model.study().create("std3");
    model.study("std3").create("stat", "Stationary");
    model.study("std3").feature("stat").setSolveFor("/physics/ht", false);

//    In the Settings window for Stationary, locate the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std3").feature("stat").set("useparam", true);

//    Click Add.

    model.study("std3").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std3").feature("stat").setIndex("plistarr", "", 0);
    model.study("std3").feature("stat").setIndex("punit", "", 0);
    model.study("std3").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std3").feature("stat").setIndex("plistarr", "", 0);
    model.study("std3").feature("stat").setIndex("punit", "", 0);

//    In the table, enter the following settings:

    model.study("std3").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std3").feature("stat").setIndex("plistarr", 0, 0);

//    In the Study toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Study 3: Water in the Label text field.

    model.study("std3").label("Study 3: Water");

//    In the Study toolbar, click Stationary.

    model.study("std3").create("stat2", "Stationary");

//    In the Settings window for Stationary, click to expand the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std3").feature("stat2").set("useparam", true);

//    Click Add.

    model.study("std3").feature("stat2").setIndex("pname", "w_EG", 0);
    model.study("std3").feature("stat2").setIndex("plistarr", "", 0);
    model.study("std3").feature("stat2").setIndex("punit", "", 0);
    model.study("std3").feature("stat2").setIndex("pname", "w_EG", 0);
    model.study("std3").feature("stat2").setIndex("plistarr", "", 0);
    model.study("std3").feature("stat2").setIndex("punit", "", 0);

//    In the table, enter the following settings:

    model.study("std3").feature("stat2").setIndex("pname", "w_EG", 0);
    model.study("std3").feature("stat2").setIndex("plistarr", 0, 0);

//    In the Study toolbar, click Show Default Solver.

    model.study("std3").showAutoSequences("all");

//    <l>Study step 2</l> uses the solution for the flow field as initial conditions. In this case Anderson acceleration can be enabled to reduce the simulation time.
//    In the Model Builder window, expand the Solution 3 (sol3) node.
//    In the Model Builder window, expand the Study 3: Water > Solver Configurations > Solution 3 (sol3) > Stationary Solver 2 node, then click Segregated 1.
//    In the Settings window for Segregated, locate the General section.
//    From the Stabilization and acceleration list, select Anderson acceleration.

    model.sol("sol3").feature("s2").feature("se1").set("segstabacc", "segaacc");

//    In the Study toolbar, click Compute.

    model.study("std3").createAutoSequences("all");

    model.sol("sol3").runAll();

    model.result().dataset("dset3").set("geom", "geom1");
    model.result().create("pg6", "PlotGroup2D");
    model.result("pg6").label("Velocity (spf)");
    model.result("pg6").set("data", "dset3");
    model.result("pg6").setIndex("looplevel", 1, 0);
    model.result("pg6").set("frametype", "spatial");
    model.result("pg6").set("smooth", "internal");
    model.result("pg6").feature().create("surf1", "Surface");
    model.result("pg6").feature("surf1").label("Surface");
    model.result("pg6").feature("surf1").set("smooth", "internal");
    model.result("pg6").feature("surf1").set("data", "parent");
    model.result().create("pg7", "PlotGroup2D");
    model.result("pg7").label("Pressure (spf)");
    model.result("pg7").set("data", "dset3");
    model.result("pg7").setIndex("looplevel", 1, 0);
    model.result("pg7").set("frametype", "spatial");
    model.result("pg7").set("smooth", "internal");
    model.result("pg7").feature().create("surf1", "Surface");
    model.result("pg7").feature("surf1").set("expr", "p");
    model.result("pg7").feature("surf1").set("colortable", "Tectocoris");
    model.result("pg7").feature("surf1").set("colortabletype", "discrete");
    model.result("pg7").feature("surf1").set("bandcount", 25);
    model.result("pg7").feature("surf1").set("smooth", "internal");
    model.result("pg7").feature("surf1").set("data", "parent");
    model.result().dataset().create("rev1", "Revolve2D");
    model.result().dataset("rev1").label("Revolution 2D");
    model.result().dataset("rev1").set("data", "none");
    model.result().dataset("rev1").set("startangle", -90);
    model.result().dataset("rev1").set("revangle", 225);
    model.result().dataset("rev1").set("data", "dset3");
    model.result().create("pg8", "PlotGroup3D");
    model.result("pg8").label("Velocity, 3D (spf)");
    model.result("pg8").set("frametype", "spatial");
    model.result("pg8").set("smooth", "internal");
    model.result("pg8").feature().create("surf1", "Surface");
    model.result("pg8").feature("surf1").label("Surface");
    model.result("pg8").feature("surf1").set("smooth", "internal");
    model.result("pg8").feature("surf1").set("data", "parent");
    model.result().create("pg9", "PlotGroup2D");
    model.result("pg9").label("Wall Resolution (spf)");
    model.result("pg9").set("data", "dset3");
    model.result("pg9").setIndex("looplevel", 1, 0);
    model.result("pg9").set("smooth", "internal");
    model.result("pg9").feature().create("line1", "Line");
    model.result("pg9").feature("line1").set("solutionparams", "parent");
    model.result("pg9").feature("line1").set("expr", "spf.Delta_wPlus");
    model.result("pg9").feature("line1").set("linetype", "tube");
    model.result("pg9").feature("line1").set("smooth", "internal");
    model.result("pg9").feature("line1").set("data", "parent");
    model.result("pg9").feature("line1").feature().create("sel1", "Selection");
    model.result("pg9").feature("line1").feature("sel1").selection().geom("geom1", 1);
    model.result("pg9").feature("line1").feature("sel1").selection()
         .set(5, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);
    model.result("pg9").feature("line1").feature().create("hght1", "Height");
    model.result("pg9").feature("line1").feature("hght1").label("Height Expression");
    model.result("pg9").feature("line1").feature("hght1").set("heightdata", "expr");
    model.result("pg9").feature("line1").feature("hght1").set("expr", "spf.WRHeightExpr");
    model.result().create("pg10", "PlotGroup2D");
    model.result("pg10").label("Temperature (ht)");
    model.result("pg10").set("data", "dset3");
    model.result("pg10").setIndex("looplevel", 1, 0);
    model.result("pg10").set("smooth", "internal");
    model.result("pg10").feature().create("surf1", "Surface");
    model.result("pg10").feature("surf1").set("solutionparams", "parent");
    model.result("pg10").feature("surf1").set("expr", "T");
    model.result("pg10").feature("surf1").set("colortable", "HeatCameraLight");
    model.result("pg10").feature("surf1").set("data", "parent");
    model.result().create("pg11", "PlotGroup2D");
    model.result("pg11").label("Temperature and Fluid Flow (nitf1)");
    model.result("pg11").set("data", "dset3");
    model.result("pg11").setIndex("looplevel", 1, 0);
    model.result("pg11").set("showlegendsunit", true);
    model.result("pg11").set("smooth", "internal");
    model.result("pg11").feature().create("surf1", "Surface");
    model.result("pg11").feature("surf1").label("Fluid Temperature");
    model.result("pg11").feature("surf1").set("solutionparams", "parent");
    model.result("pg11").feature("surf1").set("expr", "nitf1.T");
    model.result("pg11").feature("surf1").set("colortable", "HeatCameraLight");
    model.result("pg11").feature("surf1").set("smooth", "internal");
    model.result("pg11").feature("surf1").set("data", "parent");
    model.result("pg11").feature("surf1").feature().create("sel1", "Selection");
    model.result("pg11").feature("surf1").feature("sel1").selection().geom("geom1", 2);
    model.result("pg11").feature("surf1").feature("sel1").selection().set(1);
    model.result("pg11").feature().create("surf2", "Surface");
    model.result("pg11").feature("surf2").label("Solid Temperature");
    model.result("pg11").feature("surf2").set("solutionparams", "parent");
    model.result("pg11").feature("surf2").set("expr", "nitf1.T");
    model.result("pg11").feature("surf2").set("smooth", "internal");
    model.result("pg11").feature("surf2").set("data", "parent");
    model.result("pg11").feature("surf2").feature().create("sel1", "Selection");
    model.result("pg11").feature("surf2").feature("sel1").selection().geom("geom1", 2);
    model.result("pg11").feature("surf2").feature("sel1").selection().set(2);
    model.result("pg11").feature("surf2").set("inheritplot", "surf1");
    model.result("pg11").feature().create("arws1", "ArrowSurface");
    model.result("pg11").feature("arws1").label("Fluid Flow");
    model.result("pg11").feature("arws1").set("solutionparams", "parent");
    model.result("pg11").feature("arws1").set("expr", new String[]{"nitf1.ur", "nitf1.uz"});
    model.result("pg11").feature("arws1").set("xnumber", 30);
    model.result("pg11").feature("arws1").set("ynumber", 30);
    model.result("pg11").feature("arws1").set("arrowtype", "cone");
    model.result("pg11").feature("arws1").set("arrowlength", "logarithmic");
    model.result("pg11").feature("arws1").set("data", "parent");
    model.result("pg11").feature("arws1").feature().create("col1", "Color");
    model.result("pg11").feature("arws1").feature().create("filt1", "Filter");
    model.result("pg11").feature("arws1").feature("filt1").set("expr", "spf.U>nitf1.Uave");
    model.result("pg6").run();

//    In the Model Builder window, expand the Results > Datasets node.
//    Right-click Revolution 2D and choose Duplicate.

    model.result().dataset().duplicate("rev2", "rev1");

//    In the Settings window for Revolution 2D, click to expand the Revolution Layers section.
//    In the Start angle text field, type 0.

    model.result().dataset("rev2").set("startangle", 0);

//    In the Revolution angle text field, type 360.

    model.result().dataset("rev2").set("revangle", 360);

//    Right-click Revolution 2D and choose Duplicate.

    model.result().dataset().duplicate("rev3", "rev1");

//    In the Results toolbar, click Attributes and choose Selection.
//    In the Settings window for Selection, locate the Geometric Entity Selection section.
//    From the Geometric entity level list, select Boundary.

    model.result().dataset("rev3").selection().geom("geom1", 1);

//    From the Selection list, select All boundaries.

    model.result().dataset("rev3").selection().geom("geom1", 1);
    model.result().dataset("rev3").selection().all();

//    Select Boundaries 1, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23.

    model.result().dataset("rev3").selection().geom("geom1", 1);
    model.result().dataset("rev3").selection()
         .set(1, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);

//    Plot group 10 displays the flow field in the test apparatus using a revolved dataset.

    model.result("pg8").run();

//    In the Model Builder window, under Results, click Velocity, 3D (spf).
//    In the Settings window for 3D Plot Group, click to expand the Title section.
//    From the Title type list, select Manual.

    model.result("pg8").set("titletype", "manual");

//    In the Title text area, type Velocity magnitude.

    model.result("pg8").set("title", "Velocity magnitude");

//    Locate the Plot Settings section.
//    Clear the Plot dataset edges checkbox.

    model.result("pg8").set("edges", false);

//    Locate the Color Legend section.
//    Select the Show units checkbox.

    model.result("pg8").set("showlegendsunit", true);
    model.result("pg8").run();

//    In the Model Builder window, expand the Velocity, 3D (spf) node, then click Surface.
//    In the Settings window for Surface, locate the Coloring and Style section.
//    From the Color table list, select Passiflora.

    model.result("pg8").feature("surf1").set("colortable", "Passiflora");

//    In the Velocity, 3D (spf) toolbar, click Surface.

    model.result("pg8").create("surf2", "Surface");
    model.result("pg8").feature("surf2").set("evaluationsettings", "parent");

//    In the Settings window for Surface, locate the Data section.
//    From the Dataset list, select Revolution 2D 2.

    model.result("pg8").feature("surf2").set("data", "rev2");

//    In the Velocity, 3D (spf) toolbar, click Material Appearance.

    model.result("pg8").feature("surf2").create("mtrl1", "MaterialAppearance");

//    In the Settings window for Material Appearance, locate the Appearance section.
//    From the Appearance list, select Custom.

    model.result("pg8").feature("surf2").feature("mtrl1").set("appearance", "custom");

//    From the Material type list, select Steel (anodized).

    model.result("pg8").feature("surf2").feature("mtrl1").set("family", "steelanodized");
    model.result("pg8").run();

//    In the Model Builder window, click Surface 2.
//    In the Velocity, 3D (spf) toolbar, click Selection.

    model.result("pg8").feature("surf2").create("sel1", "Selection");

//    Select Domain 2.

    model.result("pg8").feature("surf2").feature("sel1").selection().set(2);
    model.result("pg8").run();

//    Right-click Surface 2 and choose Duplicate.

    model.result("pg8").feature().duplicate("surf3", "surf2");
    model.result("pg8").run();

//    In the Settings window for Surface, locate the Data section.
//    From the Dataset list, select Revolution 2D 3.

    model.result("pg8").feature("surf3").set("data", "rev3");
    model.result("pg8").run();

//    In the Model Builder window, expand the Surface 3 node, then click Selection 1.
//    In the Settings window for Selection, locate the Selection section.
//    Select the Activate Selection toggle button.
//    Select Domain 1.

    model.result("pg8").feature("surf3").feature("sel1").selection().set(1);

//    Locate the Revolution Selection section.
//    Clear the Evaluate the start cap checkbox.

    model.result("pg8").feature("surf3").feature("sel1").set("evalstartcap", false);

//    Clear the Evaluate the end cap checkbox.

    model.result("pg8").feature("surf3").feature("sel1").set("evalendcap", false);
    model.result("pg8").run();

//    Delete some superfluous plot groups.

    model.result("pg6").run();

//    In the Model Builder window, under Results, Ctrl-click to select Velocity (spf), Pressure (spf), Temperature (ht), Temperature and Fluid Flow (nitf1).
//    Right-click and choose Delete.

    model.result().remove("pg6");
    model.result().remove("pg7");
    model.result().remove("pg10");
    model.result().remove("pg11");
    model.result("pg8").run();

//    Create a 2D plot group for the temperature.
//    In the Results toolbar, click 2D Plot Group.

    model.result().create("pg10", "PlotGroup2D");
    model.result("pg10").run();

//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Dataset list, select Study 3: Water/Solution 3 (sol3).

    model.result("pg10").set("data", "dset3");

//    In the 2D Plot Group 10 toolbar, click Surface.

    model.result("pg10").create("surf1", "Surface");
    model.result("pg10").feature("surf1").set("evaluationsettings", "parent");

//    In the Settings window for Surface, locate the Expression section.
//    In the Expression text field, type T.

    model.result("pg10").feature("surf1").set("expr", "T");

//    In the 2D Plot Group 10 toolbar, click Plot.

    model.result("pg10").run();

//    Click to expand the Range section.
//    Select the Manual color range checkbox.

    model.result("pg10").feature("surf1").set("rangecoloractive", true);

//    In the Maximum text field, type 400.

    model.result("pg10").feature("surf1").set("rangecolormax", 400);

//    Locate the Coloring and Style section.
//    From the Color table list, select HeatCameraLight.

    model.result("pg10").feature("surf1").set("colortable", "HeatCameraLight");

//    In the 2D Plot Group 10 toolbar, click Plot.

    model.result("pg10").run();

//    Click the Zoom Extents button in the Graphics toolbar.

    model.result("pg10").run();

//    In the Model Builder window, under Results, click 2D Plot Group 10.
//    In the Settings window for 2D Plot Group, type Temperature in the Label text field.

    model.result("pg10").label("Temperature");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg10").set("xlabelactive", true);

//    In the associated text field, type r (m).

    model.result("pg10").set("xlabel", "r (m)");

//    Locate the Color Legend section.
//    Select the Show units checkbox.

    model.result("pg10").set("showlegendsunit", true);
    model.result("pg10").set("titletype", "auto");

//    Add a new <l>Study</l> to solve for the fluid flow and heat transfer in the test apparatus when using a coolant mixture composed of equal volumes of ethylene glycol and water. Use two study steps; One using the same inlet velocity as for the pure water case, and one where the flow rate of the ethylene/water mixture is increased by 15%.
//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Stationary.
//    Click Add Study in the window toolbar.

    model.study().create("std4");
    model.study("std4").create("stat", "Stationary");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Stationary, locate the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

    model.study("std4").feature("stat").set("useparam", true);

//    Click Add.

    model.study("std4").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std4").feature("stat").setIndex("plistarr", "", 0);
    model.study("std4").feature("stat").setIndex("punit", "", 0);
    model.study("std4").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std4").feature("stat").setIndex("plistarr", "", 0);
    model.study("std4").feature("stat").setIndex("punit", "", 0);

//     twice.

    model.study("std4").feature("stat").setIndex("pname", "w_W", 1);
    model.study("std4").feature("stat").setIndex("plistarr", "", 1);
    model.study("std4").feature("stat").setIndex("punit", "", 1);
    model.study("std4").feature("stat").setIndex("pname", "w_W", 1);
    model.study("std4").feature("stat").setIndex("plistarr", "", 1);
    model.study("std4").feature("stat").setIndex("punit", "", 1);

//    In the table, enter the following settings:

    model.study("std4").feature("stat").setIndex("pname", "w_EG", 0);
    model.study("std4").feature("stat").setIndex("plistarr", 0.527, 0);
    model.study("std4").feature("stat").setIndex("pname", "Vel", 1);
    model.study("std4").feature("stat").setIndex("plistarr", 1, 1);

//    Right-click Study 4 > Step 1: Stationary and choose Duplicate.

    model.study("std4").feature().duplicate("stat1", "stat");

//    In the Settings window for Stationary, locate the Study Extensions section.
//    In the table, enter the following settings:

    model.study("std4").feature("stat1").setIndex("plistarr", 1.15, 1);

//    In the Model Builder window, click Step 1: Stationary.
//    In the Settings window for Stationary, click to expand the Values of Dependent Variables section.
//    Find the Initial values of variables solved for subsection.
//    From the Settings list, select User controlled.

    model.study("std4").feature("stat").set("useinitsol", true);

//    From the Method list, select Solution.

    model.study("std4").feature("stat").set("initmethod", "sol");

//    From the Study list, select Study 3: Water, Stationary 2.

    model.study("std4").feature("stat").set("initstudy", "std3");

//    In the Study toolbar, click Show Default Solver.

    model.study("std4").showAutoSequences("all");

//    Apply Anderson acceleration also for the cases using ethylene glycol. Note that the previous solution, using water as coolant, was used for the initial conditions.
//    In the Model Builder window, expand the Solution 5 (sol5) node.
//    In the Model Builder window, expand the Study 4 > Solver Configurations > Solution 5 (sol5) > Stationary Solver 1 node, then click Segregated 1.
//    In the Settings window for Segregated, locate the General section.
//    From the Stabilization and acceleration list, select Anderson acceleration.

    model.sol("sol5").feature("s1").feature("se1").set("segstabacc", "segaacc");

//    In the Model Builder window, collapse the Study 4 > Solver Configurations > Solution 5 (sol5) > Stationary Solver 1 node.
//    In the Model Builder window, expand the Study 4 > Solver Configurations > Solution 5 (sol5) > Stationary Solver 2 node, then click Segregated 1.
//    In the Settings window for Segregated, locate the General section.
//    From the Stabilization and acceleration list, select Anderson acceleration.

    model.sol("sol5").feature("s2").feature("se1").set("segstabacc", "segaacc");

//    In the Model Builder window, click Study 4.
//    In the Settings window for Study, type Study 4: Glycol and Water in the Label text field.

    model.study("std4").label("Study 4: Glycol and Water");

//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std4").setGenPlots(false);

//    In the Study toolbar, click Compute.

    model.study("std4").createAutoSequences("all");

    model.sol("sol5").runAll();

//    In the Model Builder window, under Study 4: Glycol and Water > Solver Configurations > Solution 5 (sol5), click Solution Store 2 (sol6).
//    In the Settings window for Solution Store, type Vel = 1.0 m/s in the Label text field.

    model.sol("sol5").feature("su1").label("Vel = 1.0 m/s");

//    In the Model Builder window, click Solution 5 (sol5).
//    In the Settings window for Solution, type Vel = 1.15 m/s in the Label text field.

    model.sol("sol5").label("Vel = 1.15 m/s");

    model.result("pg10").run();

//    In the Model Builder window, under Results, click Temperature.
//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.0 m/s (sol6).

    model.result("pg10").set("data", "dset6");

//    In the Temperature toolbar, click Plot.

    model.result("pg10").run();
    model.result("pg10").set("titletype", "auto");

//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.15 m/s (sol5).

    model.result("pg10").set("data", "dset5");

//    In the Temperature toolbar, click Plot.

    model.result("pg10").run();

//    Create cut line datasets to evaluate the heat capacity throughout the chamber section of the apparatus. Create one line for each study case.
//    In the Results toolbar, click Cut Line 2D.

    model.result().dataset().create("cln1", "CutLine2D");

//    In the Settings window for Cut Line 2D, locate the Line Data section.
//    In row Point 1, set r to r_c*0.5.

    model.result().dataset("cln1").setIndex("genpoints", "r_c*0.5", 0, 0);

//    In row Point 2, set r to r_c*0.5.

    model.result().dataset("cln1").setIndex("genpoints", "r_c*0.5", 1, 0);

//    In row Point 2, set z to 1.

    model.result().dataset("cln1").setIndex("genpoints", 1, 1, 1);

//    Locate the Data section.
//    From the Dataset list, select Study 3: Water/Solution 3 (sol3).

    model.result().dataset("cln1").set("data", "dset3");

//    Right-click Cut Line 2D 1 and choose Duplicate.

    model.result().dataset().duplicate("cln2", "cln1");

//    In the Settings window for Cut Line 2D, locate the Data section.
//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.0 m/s (sol6).

    model.result().dataset("cln2").set("data", "dset6");

//    Right-click Cut Line 2D 2 and choose Duplicate.

    model.result().dataset().duplicate("cln3", "cln2");

//    In the Settings window for Cut Line 2D, locate the Data section.
//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.15 m/s (sol5).

    model.result().dataset("cln3").set("data", "dset5");

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg11", "PlotGroup1D");
    model.result("pg11").run();

//    In the 1D Plot Group 11 toolbar, click Line Graph.

    model.result("pg11").create("lngr1", "LineGraph");
    model.result("pg11").feature("lngr1").set("markerpos", "datapoints");
    model.result("pg11").feature("lngr1").set("linewidth", "preference");
    model.result("pg11").feature("lngr1").set("evaluationsettings", "parent");

//    In the Settings window for Line Graph, locate the Data section.
//    From the Dataset list, select Cut Line 2D 1.

    model.result("pg11").feature("lngr1").set("data", "cln1");

//    Locate the y-Axis Data section.
//    In the Expression text field, type ht.Cp.

    model.result("pg11").feature("lngr1").set("expr", "ht.Cp");

//    In the 1D Plot Group 11 toolbar, click Plot.

    model.result("pg11").run();

//    Click to expand the Legends section.
//    Select the Show legends checkbox.

    model.result("pg11").feature("lngr1").set("legend", true);

//    From the Legends list, select Manual.

    model.result("pg11").feature("lngr1").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg11").feature("lngr1").setIndex("legends", "Water", 0);

//    In the 1D Plot Group 11 toolbar, click Plot.

    model.result("pg11").run();

//    Right-click Line Graph 1 and choose Duplicate.

    model.result("pg11").feature().duplicate("lngr2", "lngr1");
    model.result("pg11").run();

//    In the Settings window for Line Graph, locate the Data section.
//    From the Dataset list, select Cut Line 2D 2.

    model.result("pg11").feature("lngr2").set("data", "cln2");

//    Locate the Legends section.
//    In the table, enter the following settings:

    model.result("pg11").feature("lngr2").setIndex("legends", "Glycol/Water", 0);

//    In the 1D Plot Group 11 toolbar, click Plot.

    model.result("pg11").run();

//    Right-click Line Graph 2 and choose Duplicate.

    model.result("pg11").feature().duplicate("lngr3", "lngr2");
    model.result("pg11").run();

//    In the Settings window for Line Graph, locate the Data section.
//    From the Dataset list, select Cut Line 2D 3.

    model.result("pg11").feature("lngr3").set("data", "cln3");

//    Locate the Legends section.
//    In the table, enter the following settings:

    model.result("pg11").feature("lngr3").setIndex("legends", "Glycol/Water, Vel = 1.15 m/s", 0);

//    In the 1D Plot Group 11 toolbar, click Plot.

    model.result("pg11").run();
    model.result("pg11").run();

    return model;
  }

  public static Model run4(Model model) {

//    In the Model Builder window, click 1D Plot Group 11.
//    In the Settings window for 1D Plot Group, locate the Legend section.
//    From the Position list, select Middle right.

    model.result("pg11").set("legendpos", "middleright");

//    Locate the Title section.
//    From the Title type list, select None.

    model.result("pg11").set("titletype", "none");

//    In the Label text field, type Heat Capacity, Chamber Cut Line.

    model.result("pg11").label("Heat Capacity, Chamber Cut Line");

//    Compute the average mixture property values.
//    In the Results toolbar, click More Derived Values and choose Average > Surface Average.

    model.result().numerical().create("av1", "AvSurface");
    model.result().numerical("av1").set("intvolume", true);

//    In the Settings window for Surface Average, locate the Data section.
//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.0 m/s (sol6).

    model.result().numerical("av1").set("data", "dset6");

//    Select Domain 1.

    model.result().numerical("av1").selection().set(1);

//    Locate the Expressions section.
//    In the table, enter the following settings:

    model.result().numerical("av1").setIndex("expr", "ht.rho", 0);
    model.result().numerical("av1").setIndex("unit", "kg/m^3", 0);
    model.result().numerical("av1").setIndex("descr", "Density", 0);
    model.result().numerical("av1").setIndex("expr", "ht.Cp", 1);
    model.result().numerical("av1").setIndex("unit", "J/(kg*K)", 1);
    model.result().numerical("av1").setIndex("descr", "Heat capacity at constant pressure", 1);
    model.result().numerical("av1").setIndex("expr", "ht.krr", 2);
    model.result().numerical("av1").setIndex("unit", "W/(m*K)", 2);
    model.result().numerical("av1").setIndex("descr", "Thermal conductivity, rr component", 2);
    model.result().numerical("av1").setIndex("expr", "spf.mu", 3);
    model.result().numerical("av1").setIndex("unit", "Pa*s", 3);
    model.result().numerical("av1").setIndex("descr", "Dynamic viscosity", 3);

//    Click Evaluate.

    model.result().table().create("tbl1", "Table");
    model.result().table("tbl1").comments("Surface Average 1");
    model.result().numerical("av1").set("table", "tbl1");
    model.result().numerical("av1").setResult();

//    Store the average property values as parameters.
//    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("rhoC", "1010[kg/m^3]");
    model.param().descr("rhoC", "Average constant density");
    model.param().set("CpC", "3486[J/kg/K]");
    model.param().descr("CpC", "Average constant heat capacity");
    model.param().set("kC", "0.574[W/m/K]");
    model.param().descr("kC", "Average constant conductivity");
    model.param().set("muC", "9.07e-4[Pa*s]");
    model.param().descr("muC", "Average constant viscosity");

//    Finally compute the flow and heat in the test apparatus using the average values for the mixture properties.
//    In the Model Builder window, under Component 1 (comp1) > Heat Transfer in Fluids (ht), click Fluid 1.
//    In the Settings window for Fluid, locate the Heat Conduction, Fluid section.
//    From the \[k_{\textrm{}}\] list, select User defined.

    model.component("comp1").physics("ht").feature("fluid1").set("k_mat", "userdef");

//    In the associated text field, type kC.

    model.component("comp1").physics("ht").feature("fluid1")
         .set("k", new String[]{"kC", "0", "0", "0", "kC", "0", "0", "0", "kC"});

//    Locate the Thermodynamics, Fluid section.
//    From the Fluid type list, select Gas/Liquid.

    model.component("comp1").physics("ht").feature("fluid1").set("fluidType", "gasLiquid");

//    From the \[\rho_{\textrm{}}\] list, select User defined.

    model.component("comp1").physics("ht").feature("fluid1").set("rho_mat", "userdef");

//    In the associated text field, type rhoC.

    model.component("comp1").physics("ht").feature("fluid1").set("rho", "rhoC");

//    From the \[C_{p{\textrm{}}}\] list, select User defined.

    model.component("comp1").physics("ht").feature("fluid1").set("Cp_mat", "userdef");

//    In the associated text field, type CpC.

    model.component("comp1").physics("ht").feature("fluid1").set("Cp", "CpC");

//    In the Model Builder window, under Component 1 (comp1) > Turbulent Flow, k-ε (spf), click Fluid Properties 1.
//    In the Settings window for Fluid Properties, locate the Fluid Properties section.
//    From the \[\mu\] list, select User defined.

    model.component("comp1").physics("spf").feature("fp1").set("mu_mat", "userdef");

//    In the associated text field, type muC.

    model.component("comp1").physics("spf").feature("fp1").set("mu", "muC");

//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select General Studies > Stationary.
//    Click Add Study in the window toolbar.

    model.study().create("std5");
    model.study("std5").create("stat", "Stationary");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Stationary, locate the Values of Dependent Variables section.
//    Find the Initial values of variables solved for subsection.
//    From the Settings list, select User controlled.

    model.study("std5").feature("stat").set("useinitsol", true);

//    From the Method list, select Solution.

    model.study("std5").feature("stat").set("initmethod", "sol");

//    From the Study list, select Study 3: Water, Stationary 2.

    model.study("std5").feature("stat").set("initstudy", "std3");

//    In the Model Builder window, click Study 5.
//    In the Settings window for Study, type Study 5: Glycol and Water, Constant Properties in the Label text field.

    model.study("std5").label("Study 5: Glycol and Water, Constant Properties");

//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std5").setGenPlots(false);

//    In the Study toolbar, click Compute.

    model.study("std5").createAutoSequences("all");

    model.sol("sol7").runAll();

//    Plot the temperature for the case with average values for the mixture properties.

    model.result("pg10").run();

//    In the Model Builder window, under Results, click Temperature.
//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Dataset list, select Study 5: Glycol and Water, Constant Properties/Solution 7 (sol7).

    model.result("pg10").set("data", "dset7");

//    In the Temperature toolbar, click Plot.

    model.result("pg10").run();
    model.result("pg10").set("titletype", "auto");

//    Compute the outlet temperature, the average pressure drop, and the average outlet density.
//    In the Results toolbar, click Point Evaluation.

    model.result().numerical().create("pev1", "EvalPoint");

//    Select Point 6.

    model.result().numerical("pev1").selection().set(6);

//    In the Settings window for Point Evaluation, locate the Expressions section.
//    In the table, enter the following settings:

    model.result().numerical("pev1").setIndex("expr", "T", 0);
    model.result().numerical("pev1").setIndex("unit", "", 0);
    model.result().numerical("pev1").setIndex("descr", "", 0);

//    Locate the Data section.
//    From the Dataset list, select Study 3: Water/Solution 3 (sol3).

    model.result().numerical("pev1").set("data", "dset3");

//    Click Evaluate.

    model.result().table().create("tbl2", "Table");
    model.result().table("tbl2").comments("Point Evaluation 1");
    model.result().numerical("pev1").set("table", "tbl2");
    model.result().numerical("pev1").setResult();

//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.0 m/s (sol6).

    model.result().numerical("pev1").set("data", "dset6");

//    Click ^ next to Evaluate then choose New Table.

    model.result().table().create("tbl3", "Table");
    model.result().table("tbl3").comments("Point Evaluation 1");
    model.result().numerical("pev1").set("table", "tbl3");
    model.result().numerical("pev1").setResult();

//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.15 m/s (sol5).

    model.result().numerical("pev1").set("data", "dset5");

//    Click ^ next to Evaluate then choose New Table.

    model.result().table().create("tbl4", "Table");
    model.result().table("tbl4").comments("Point Evaluation 1");
    model.result().numerical("pev1").set("table", "tbl4");
    model.result().numerical("pev1").setResult();

//    From the Dataset list, select Study 5: Glycol and Water, Constant Properties/Solution 7 (sol7).

    model.result().numerical("pev1").set("data", "dset7");

//    Click ^ next to Evaluate then choose New Table.

    model.result().table().create("tbl5", "Table");
    model.result().table("tbl5").comments("Point Evaluation 1");
    model.result().numerical("pev1").set("table", "tbl5");
    model.result().numerical("pev1").setResult();

//    In the Results toolbar, click More Derived Values and choose Average > Line Average.

    model.result().numerical().create("av2", "AvLine");
    model.result().numerical("av2").set("intsurface", true);

//    Select Boundary 2.

    model.result().numerical("av2").selection().set(2);

//    In the Settings window for Line Average, locate the Expressions section.
//    In the table, enter the following settings:

    model.result().numerical("av2").setIndex("expr", "p", 0);
    model.result().numerical("av2").setIndex("unit", "", 0);
    model.result().numerical("av2").setIndex("descr", "", 0);

//    Locate the Data section.
//    From the Dataset list, select Study 3: Water/Solution 3 (sol3).

    model.result().numerical("av2").set("data", "dset3");

//    Click ^ next to Evaluate then choose Table 2 - Point Evaluation 1.

    model.result().numerical("av2").set("table", "tbl2");
    model.result().numerical("av2").appendResult();

//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.0 m/s (sol6).

    model.result().numerical("av2").set("data", "dset6");

//    Click ^ next to Evaluate then choose Table 3 - Point Evaluation 1.

    model.result().numerical("av2").set("table", "tbl3");
    model.result().numerical("av2").appendResult();

//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.15 m/s (sol5).

    model.result().numerical("av2").set("data", "dset5");

//    Click ^ next to Evaluate then choose Table 4 - Point Evaluation 1.

    model.result().numerical("av2").set("table", "tbl4");
    model.result().numerical("av2").appendResult();

//    From the Dataset list, select Study 5: Glycol and Water, Constant Properties/Solution 7 (sol7).

    model.result().numerical("av2").set("data", "dset7");

//    Click ^ next to Evaluate then choose Table 5 - Point Evaluation 1.

    model.result().numerical("av2").set("table", "tbl5");
    model.result().numerical("av2").appendResult();

//    In the Results toolbar, click More Derived Values and choose Average > Line Average.

    model.result().numerical().create("av3", "AvLine");
    model.result().numerical("av3").set("intsurface", true);

//    Select Boundary 11.

    model.result().numerical("av3").selection().set(11);

//    In the Settings window for Line Average, locate the Expressions section.
//    In the table, enter the following settings:

    model.result().numerical("av3").setIndex("expr", "ht.rho", 0);
    model.result().numerical("av3").setIndex("unit", "", 0);
    model.result().numerical("av3").setIndex("descr", "", 0);

//    Locate the Data section.
//    From the Dataset list, select Study 3: Water/Solution 3 (sol3).

    model.result().numerical("av3").set("data", "dset3");

//    Click ^ next to Evaluate then choose Table 2 - Point Evaluation 1.

    model.result().numerical("av3").set("table", "tbl2");
    model.result().numerical("av3").appendResult();

//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.0 m/s (sol6).

    model.result().numerical("av3").set("data", "dset6");

//    Click ^ next to Evaluate then choose Table 3 - Point Evaluation 1.

    model.result().numerical("av3").set("table", "tbl3");
    model.result().numerical("av3").appendResult();

//    From the Dataset list, select Study 4: Glycol and Water/Vel = 1.15 m/s (sol5).

    model.result().numerical("av3").set("data", "dset5");

//    Click ^ next to Evaluate then choose Table 4 - Point Evaluation 1.

    model.result().numerical("av3").set("table", "tbl4");
    model.result().numerical("av3").appendResult();

//    From the Dataset list, select Study 5: Glycol and Water, Constant Properties/Solution 7 (sol7).

    model.result().numerical("av3").set("data", "dset7");

//    Click ^ next to Evaluate then choose Table 5 - Point Evaluation 1.

    model.result().numerical("av3").set("table", "tbl5");
    model.result().numerical("av3").appendResult();

    model.component("comp1").physics("spf").feature("fp1").set("mu_mat", "from_mat");
    model.component("comp1").physics("ht").feature("fluid1").set("k_mat", "from_mat");
    model.component("comp1").physics("ht").feature("fluid1").set("rho_mat", "from_mat");
    model.component("comp1").physics("ht").feature("fluid1").set("Cp_mat", "from_mat");

    model.result("pg10").run();
    model.result("pg10").set("data", "dset6");
    model.result("pg10").run();

    model.title("Engine Coolant Properties");

    model
         .description("The engine block of a car includes a cooling jacket to remove excess heat from combustion. The cooling jacket consists of open spaces in the cylinder block and the cylinder head. When the engine is running, a coolant fluid is pumped through the jacket to keep the engine from overheating. Optimizing the heat removal is important to minimize coolant boiling, prevent engine failure, and, more recently, improve overall efficiency through waste heat recovery. This example demonstrates how the Thermodynamics feature can be used to evaluate the performance of different engine coolants.");

    return model;
  }

  public static void main(String[] args) {
    Model model = run();
    model = run2(model);
    model = run3(model);
    run4(model);
  }

}
