/*
 * cubic_autocatalysis.java
 */

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

/** Model exported on May 12 2026, 13:48 by COMSOL 6.4.0.418. */
public class cubic_autocatalysis {

  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 0D.
//    In the Select Physics tree, select Chemical Species Transport > Reaction Engineering (re).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Time Dependent.
//    Click Done.

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

    model.component("comp1").physics().create("re", "ReactionEng");

    model.study().create("std1");
    model.study("std1").create("time", "Transient");

//    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 cubic_autocatalysis_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("k", "0.0609[1/s]", "rate constant");
    model.param().set("f", "0.06[1/s]", "feed rate");
    model.param().set("l", "1[m]", "length");
    model.param().set("c0", "1[mol/m^3]", "reference concentration");
    model.param().set("DA", "2e-5[m^2/s]", "diffusion coefficient for A");
    model.param().set("DB", "1e-5[m^2/s]", "diffusion coefficient for B");

//    In the Reaction Engineering toolbar, click Reaction.

    model.component("comp1").physics("re").create("rch1", "ReactionChem", -1);

//    In the Settings window for Reaction, locate the Reaction Formula section.
//    In the Formula text field, type A+2B=>3B.

    model.component("comp1").physics("re").feature("rch1").set("formula", "A+2B=>3B");

//    In the Model Builder window, click Species: B.
//    In the Settings window for Species, locate the Chemical Formula section.
//    Clear the Enable formula checkbox.

    model.component("comp1").physics("re").feature("B").set("enableChemicalFormulaCheckbox", false);

//    In the Reaction Engineering toolbar, click Reaction.

    model.component("comp1").physics("re").create("rch2", "ReactionChem", -1);

//    In the Settings window for Reaction, locate the Reaction Formula section.
//    In the Formula text field, type B=>0B.

    model.component("comp1").physics("re").feature("rch2").set("formula", "B=>0B");

//    Locate the Rate Constants section.
//    In the \[k^{\textrm{f}}\] text field, type f+k.

    model.component("comp1").physics("re").feature("rch2").set("kf", "f+k");

//    In the Reaction Engineering toolbar, click Reaction.

    model.component("comp1").physics("re").create("rch3", "ReactionChem", -1);

//    In the Settings window for Reaction, locate the Reaction Formula section.
//    In the Formula text field, type A=>0A.

    model.component("comp1").physics("re").feature("rch3").set("formula", "A=>0A");

//    Locate the Rate Constants section.
//    In the \[k^{\textrm{f}}\] text field, type f.

    model.component("comp1").physics("re").feature("rch3").set("kf", "f");

//    In the Reaction Engineering toolbar, click Additional Source.

    model.component("comp1").physics("re").create("add1", "AdditionalSourceFeature", -1);

//    In the Settings window for Additional Source, locate the Additional Rate Expression section.
//    In the Volumetric species table, enter the following settings:

    model.component("comp1").physics("re").feature("add1").setIndex("AddR", "f", 0, 0);

//    In the Model Builder window, click Initial Values 1.
//    In the Settings window for Initial Values, locate the Volumetric Species Initial Values section.
//    In the table, enter the following settings:

    model.component("comp1").physics("re").feature("inits1").setIndex("initialValue", 1, 1, 0);

//    In the Study toolbar, click Parametric Sweep.

    model.study("std1").create("param", "Parametric");

//    In the Settings window for Parametric Sweep, locate the Study Settings section.
//    Click Add.

    model.study("std1").feature("param").setIndex("pname", "k", 0);
    model.study("std1").feature("param").setIndex("plistarr", "", 0);
    model.study("std1").feature("param").setIndex("punit", "1/s", 0);
    model.study("std1").feature("param").setIndex("pname", "k", 0);
    model.study("std1").feature("param").setIndex("plistarr", "", 0);
    model.study("std1").feature("param").setIndex("punit", "1/s", 0);

//    In the table, enter the following settings:

    model.study("std1").feature("param").setIndex("plistarr", "range(0.0602, 1e-5, 0.0603)", 0);
    model.study("std1").feature("param").setIndex("punit", "1/s", 0);

//    In the Model Builder window, click Step 1: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0,5,500).

    model.study("std1").feature("time").set("tlist", "range(0,5,500)");

//    In the Study toolbar, click Compute.

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

    model.sol().create("sol2");
    model.sol("sol2").study("std1");
    model.sol("sol2").label("Parametric Solutions 1");

    model.batch("p1").feature("so1").set("psol", "sol2");
    model.batch("p1").run("compute");

    model.result().create("pg1", "PlotGroup1D");
    model.result("pg1").set("data", "dset2");
    model.result("pg1").create("glob1", "Global");
    model.result("pg1").feature("glob1").set("unit", new String[]{"", ""});
    model.result("pg1").feature("glob1").set("expr", new String[]{"re.c_A", "re.c_B"});
    model.result("pg1").feature("glob1").set("descr", new String[]{"Concentration", "Concentration"});
    model.result("pg1").label("Concentration (re)");
    model.result("pg1").feature("glob1").set("xdatasolnumtype", "level1");
    model.result("pg1").run();

//    In the Model Builder window, expand the Results > Concentration (re) node, then click Concentration (re).
//    In the Settings window for 1D Plot Group, click to expand the Title section.
//    From the Title type list, select None.

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

//    In the Model Builder window, right-click Global 1 and choose Color Expression.

    model.result("pg1").feature("glob1").create("col1", "Color");
    model.result("pg1").run();

//    In the Settings window for Color Expression, locate the Expression section.
//    In the Expression text field, type k-0.0602.

    model.result("pg1").feature("glob1").feature("col1").set("expr", "k-0.0602");

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

    model.result("pg1").feature("glob1").feature("col1").set("colortable", "Viridis");

//    From the Color table transformation list, select Reverse.

    model.result("pg1").feature("glob1").feature("col1").set("colortabletrans", "reverse");
    model.result("pg1").run();

//    In the Model Builder window, click Global 1.
//    In the Settings window for Global, locate the y-Axis Data section.
//    Click Clear Table.

    model.result("pg1").feature("glob1").set("expr", new String[]{});
    model.result("pg1").feature("glob1").set("descr", new String[]{});

//    In the table, enter the following settings:

    model.result("pg1").feature("glob1").setIndex("expr", "re.c_A", 0);
    model.result("pg1").feature("glob1").setIndex("unit", "mol/m^3", 0);
    model.result("pg1").feature("glob1").setIndex("descr", "Concentration", 0);

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

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

//    Right-click Results > Concentration (re) > Global 1 and choose Duplicate.

    model.result("pg1").feature().duplicate("glob2", "glob1");
    model.result("pg1").run();

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

    model.result("pg1").feature("glob2").setIndex("expr", "re.c_B", 0);
    model.result("pg1").feature("glob2").setIndex("unit", "mol/m^3", 0);
    model.result("pg1").feature("glob2").setIndex("descr", "Concentration", 0);

//    Click to expand the Coloring and Style section.
//    Find the Line style subsection.
//    From the Line list, select Dash-dot.

    model.result("pg1").feature("glob2").set("linestyle", "dashdot");
    model.result("pg1").run();

//    In the Model Builder window, expand the Global 2 node, then click Color Expression 1.
//    In the Settings window for Color Expression, locate the Coloring and Style section.
//    Clear the Color legend checkbox.

    model.result("pg1").feature("glob2").feature("col1").set("colorlegend", false);
    model.result("pg1").run();

//    In the Model Builder window, right-click Concentration (re) and choose Annotation.

    model.result("pg1").create("ann1", "Annotation");

//    In the Settings window for Annotation, locate the Position section.
//    In the x text field, type 150.

    model.result("pg1").feature("ann1").set("posxexpr", 150);

//    In the y text field, type 0.593.

    model.result("pg1").feature("ann1").set("posyexpr", 0.593);

//    Locate the Annotation section.
//    In the Text text field, type solid lines: [A].

    model.result("pg1").feature("ann1").set("text", "solid lines: [A]");

//    Locate the Coloring and Style section.
//    From the Anchor point list, select Lower left.

    model.result("pg1").feature("ann1").set("anchorpoint", "lowerleft");

//    Right-click Annotation 1 and choose Duplicate.

    model.result("pg1").feature().duplicate("ann2", "ann1");
    model.result("pg1").run();

//    In the Settings window for Annotation, locate the Annotation section.
//    In the Text text field, type dashed lines: [B].

    model.result("pg1").feature("ann2").set("text", "dashed lines: [B]");

//    Locate the Position section.
//    In the y text field, type 0.203.

    model.result("pg1").feature("ann2").set("posyexpr", 0.203);

//    Locate the Coloring and Style section.
//    From the Anchor point list, select Upper left.

    model.result("pg1").feature("ann2").set("anchorpoint", "upperleft");

//    In the Concentration (re) toolbar, click Plot.

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

//    In the Reaction Engineering toolbar, click Generate Space-Dependent Model.

    model.component("comp1").physics("re").create("sync1", "ReactionToMph", -1);

//    In the Settings window for Generate Space-Dependent Model, locate the Component Settings section.
//    From the Component to use list, select 2D: New.

    model.component("comp1").physics("re").feature("sync1").set("geomToUse", "2D");

//    Locate the Study Type section.
//    From the Study type list, select Time dependent.

    model.component("comp1").physics("re").feature("sync1").set("study", "Transient");

//    Locate the Space-Dependent Model Generation section.
//    Click Create/Refresh.

    model.component("comp1").physics("re").prop("synchronize").set("synchronize", "1");

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

    model.component("comp2").geom().create("geom1", 2);
    model.component("comp2").geom("geom1").axisymmetric(false);
    model.component("comp2").geom("geom1").label("Geometry 1(2D)");

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

    model.study().create("std2");
    model.study("std2").create("time", "Transient");

    model.component("comp1").physics("re").feature("sync1").set("genom", new String[]{"comp2:geom1"});
    model.component("comp1").physics("re").feature("sync1").set("studyname", new String[]{"comp2:std2"});
    model.component("comp2").physics().create("chem", "Chemistry", "geom1");
    model.component("comp2").physics().move("chem", 0);
    model.component("comp2").physics().create("tds", "DilutedSpecies", "geom1");
    model.component("comp2").physics("chem").prop("TPFeatureInput").set("T_src", "userdef");
    model.component("comp2").physics("chem").prop("TPFeatureInput").set("T", "293.15[K]");
    model.component("comp2").physics("chem").prop("mixture").set("mixture", "gas");
    model.component("comp2").physics("chem").prop("mixture").set("gasDensitySel", "Automatic");
    model.component("comp2").physics("chem").prop("Activity").set("useActivity", "0");
    model.component("comp2").physics("chem").prop("chemkin").set("chemkin", "0");
    model.component("comp2").physics("chem").prop("ChemistryCommonProperty")
         .set("VolumetricConcentrationGlobalActivityStandardState", "1[mol/m^3]");
    model.component("comp2").physics("chem").prop("ChemistryCommonProperty")
         .set("SurfaceSpeciesConcentrationType", "SurfaceConcentration");
    model.component("comp2").physics("chem").prop("ChemistryCommonProperty")
         .set("SurfaceGlobalActivityStandardState", "1[mol/m^2]");
    model.component("comp2").physics("chem").prop("ChemistryCommonProperty")
         .set("SpeciesrateUserDefinedList", new String[]{});
    model.component("comp2").physics("chem").prop("ChemistryCommonProperty").set("AdditionalSourceFeature", "1");
    model.component("comp2").physics("chem").prop("ActiveSpecies").set("SumActiveSpecies", "2");
    model.component("comp2").physics("chem").prop("ActiveSpecies").set("NumActiveVolumeSpecies", "2");
    model.component("comp2").physics("chem").prop("ActiveSpecies").set("NumActiveSurfaceSpecies", "0");
    model.component("comp2").physics("chem").prop("ActiveSpecies").set("NumActiveSurfaceSpeciesVariable", "0");
    model.component("comp2").physics("chem").prop("ActiveSpecies").set("surface", "0");
    model.component("comp2").physics("chem").prop("solventIsSet").set("solventIsSet", "0");
    model.component("comp2").physics("chem").create("rch1", "ReactionChem");
    model.component("comp2").physics("chem").feature("rch1").set("rSequenceNo", "1");
    model.component("comp2").physics("chem").feature("rch1").set("formula", "A + 2 B => 3 B");
    model.component("comp2").physics("chem").feature("rch1").set("updatechem", "0");
    model.component("comp2").physics("chem").feature("rch1").set("useArrhenius", "0");
    model.component("comp2").physics("chem").feature("rch1").set("kf", "1");
    model.component("comp2").physics("chem").feature("rch1").set("bulkFwdOrder", "3");
    model.component("comp2").physics("chem").feature("rch1").set("surfFwdOrder", "0");
    model.component("comp2").physics("chem").feature("rch1").label("1: A + 2 B => 3 B");
    model.component("comp2").physics("chem").feature("rch1").set("rClass", "volumetric");
    model.component("comp2").physics("chem").create("rch2", "ReactionChem");
    model.component("comp2").physics("chem").feature("rch2").set("rSequenceNo", "2");
    model.component("comp2").physics("chem").feature("rch2").set("formula", "B => 0 B");
    model.component("comp2").physics("chem").feature("rch2").set("updatechem", "0");
    model.component("comp2").physics("chem").feature("rch2").set("useArrhenius", "0");
    model.component("comp2").physics("chem").feature("rch2").set("kf", "f+k");
    model.component("comp2").physics("chem").feature("rch2").set("bulkFwdOrder", "1");
    model.component("comp2").physics("chem").feature("rch2").set("surfFwdOrder", "0");
    model.component("comp2").physics("chem").feature("rch2").label("2: B => 0 B");
    model.component("comp2").physics("chem").feature("rch2").set("rClass", "volumetric");
    model.component("comp2").physics("chem").create("rch3", "ReactionChem");
    model.component("comp2").physics("chem").feature("rch3").set("rSequenceNo", "3");
    model.component("comp2").physics("chem").feature("rch3").set("formula", "A => 0 A");
    model.component("comp2").physics("chem").feature("rch3").set("updatechem", "0");
    model.component("comp2").physics("chem").feature("rch3").set("useArrhenius", "0");
    model.component("comp2").physics("chem").feature("rch3").set("kf", "f");
    model.component("comp2").physics("chem").feature("rch3").set("bulkFwdOrder", "1");
    model.component("comp2").physics("chem").feature("rch3").set("surfFwdOrder", "0");
    model.component("comp2").physics("chem").feature("rch3").label("3: A => 0 A");
    model.component("comp2").physics("chem").feature("rch3").set("rClass", "volumetric");
    model.component("comp2").physics("chem").feature("A").set("SpeciesSource", "Reaction");
    model.component("comp2").physics("chem").feature("A").set("sisDef", "1");
    model.component("comp2").physics("chem").feature("A").set("specLabel", "A");
    model.component("comp2").physics("chem").feature("A").set("speciesNameInput", "A");
    model.component("comp2").physics("chem").feature("A").set("specName", "A");
    model.component("comp2").physics("chem").feature("A").set("enableChemicalFormulaCheckbox", "0");
    model.component("comp2").physics("chem").feature("A").set("chemicalFormula", "");
    model.component("comp2").physics("chem").feature("A").set("sType", "volumetric");
    model.component("comp2").physics("chem").feature("A").set("M", "0.0[kg/mol]");
    model.component("comp2").physics("chem").feature("A").set("z", "0");
    model.component("comp2").physics("chem").feature("A").set("sigma", "3.458[angstrom]");
    model.component("comp2").physics("chem").feature("A").set("epsilonkb", "107.4[K]");
    model.component("comp2").physics("chem").feature("A").set("mu", "0[C*m]");
    model.component("comp2").physics("chem").feature("A").set("rho", "1000[kg/m^3]");
    model.component("comp2").physics("chem").feature("A").set("k", "0.02[W/(m*K)]");
    model.component("comp2").physics("chem").feature("A").set("ActivityCoefficient", "1");
    model.component("comp2").physics("chem").feature("A").set("cLock", "0");
    model.component("comp2").physics("chem").feature("A").set("Dependent", "0");
    model.component("comp2").physics("chem").feature("A").set("dependent", "0");
    model.component("comp2").physics("chem").feature("A").set("SpeciesrateSelection", "Automatic");
    model.component("comp2").physics("chem").feature("A").set("AdditionalSource", "1");
    model.component("comp2").physics("chem").feature("A").set("AddR", "f");
    model.component("comp2").physics("chem").feature("A").set("speciesEnthalpy", "NASA");
    model.component("comp2").physics("chem").feature("A").set("Tlo", "300[K]");
    model.component("comp2").physics("chem").feature("A").set("Tmid", "1000[K]");
    model.component("comp2").physics("chem").feature("A").set("Thi", "5000[K]");
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaLo1", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaLo2", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaLo3", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaLo4", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaLo5", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaLo6", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaLo7", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaHi1", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaHi2", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaHi3", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaHi4", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaHi5", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaHi6", new String[]{"0"});
    model.component("comp2").physics("chem").feature("A").set("SpeciesThermoaHi7", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesSource", "Reaction");
    model.component("comp2").physics("chem").feature("B").set("sisDef", "1");
    model.component("comp2").physics("chem").feature("B").set("specLabel", "B");
    model.component("comp2").physics("chem").feature("B").set("speciesNameInput", "B");
    model.component("comp2").physics("chem").feature("B").set("specName", "B");
    model.component("comp2").physics("chem").feature("B").set("enableChemicalFormulaCheckbox", "0");
    model.component("comp2").physics("chem").feature("B").set("chemicalFormula", "B");
    model.component("comp2").physics("chem").feature("B").set("sType", "volumetric");
    model.component("comp2").physics("chem").feature("B").set("M", "10.8135[g/mol]");
    model.component("comp2").physics("chem").feature("B").set("z", "0");
    model.component("comp2").physics("chem").feature("B").set("sigma", "3.458[angstrom]");
    model.component("comp2").physics("chem").feature("B").set("epsilonkb", "107.4[K]");
    model.component("comp2").physics("chem").feature("B").set("mu", "0[C*m]");
    model.component("comp2").physics("chem").feature("B").set("rho", "1000[kg/m^3]");
    model.component("comp2").physics("chem").feature("B").set("k", "0.02[W/(m*K)]");
    model.component("comp2").physics("chem").feature("B").set("ActivityCoefficient", "1");
    model.component("comp2").physics("chem").feature("B").set("cLock", "0");
    model.component("comp2").physics("chem").feature("B").set("Dependent", "0");
    model.component("comp2").physics("chem").feature("B").set("dependent", "0");
    model.component("comp2").physics("chem").feature("B").set("SpeciesrateSelection", "Automatic");
    model.component("comp2").physics("chem").feature("B").set("AdditionalSource", "1");
    model.component("comp2").physics("chem").feature("B").set("AddR", "0");
    model.component("comp2").physics("chem").feature("B").set("speciesEnthalpy", "NASA");
    model.component("comp2").physics("chem").feature("B").set("Tlo", "300[K]");
    model.component("comp2").physics("chem").feature("B").set("Tmid", "1000[K]");
    model.component("comp2").physics("chem").feature("B").set("Thi", "5000[K]");
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaLo1", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaLo2", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaLo3", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaLo4", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaLo5", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaLo6", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaLo7", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaHi1", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaHi2", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaHi3", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaHi4", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaHi5", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaHi6", new String[]{"0"});
    model.component("comp2").physics("chem").feature("B").set("SpeciesThermoaHi7", new String[]{"0"});
    model.component("comp2").physics("chem").prop("simpropChem").set("rSequenceNo", "3");
    model.component("comp2").physics("chem").prop("simpropChem").set("sSequenceNo", "2");
    model.component("comp2").physics("chem").prop("mixture").set("hasPropertyPackage", "0");
    model.component("comp2").physics("chem").prop("mixture").set("PropertyPackage", "");
    model.component("comp2").physics("chem").prop("mixture").set("Thermodynamics", "0");
    model.component("comp2").physics("tds").field("concentration").component(new String[]{"cA", "cB"});
    model.component("comp2").physics("tds").feature("init1").set("initc", new String[]{"0", "1"});
    model.component("comp2").physics("tds").feature().create("reac1", "Reactions");
    model.component("comp2").physics("tds").feature("reac1").selection().all();
    model.component("comp2").physics("tds").feature("reac1").set("ReactingVolumeType", "TotalVolume");
    model.component("comp2").physics("chem").prop("ChemistryModelInputParameter").set("MassTransfer", "tds");
    model.component("comp2").physics("chem").prop("ChemistryModelInputParameter")
         .set("ConcentrationInput", new String[]{"cA", "cB"});
    model.component("comp2").physics("chem").prop("ChemistryModelInputParameter")
         .set("ConcentrationValue", new String[]{"Solved for", "Solved for"});
    model.component("comp2").physics("chem").prop("ChemistryModelInputParameter")
         .set("uselog", new String[]{"cA", "cB"});
    model.component("comp2").physics("chem").prop("ChemistryModelInputParameter")
         .set("SolidConcentration", new String[]{});
    model.component("comp2").physics("chem").prop("ChemistryModelInputParameter").set("csurf", new String[]{});
    model.component("comp2").physics("chem").prop("ChemistryModelInputParameter")
         .set("AqueousSpeciesConcentration", new String[]{});
    model.component("comp2").physics("tds").feature("sp1")
         .set("z", new String[]{"root.comp2.chem.z_A", "root.comp2.chem.z_B"});
    model.component("comp2").physics("tds").feature("cdm1").set("Dchem_cA", "1e-5[m^2/s]");
    model.component("comp2").physics("tds").feature("cdm1").set("D_cA", "1e-5[m^2/s]");
    model.component("comp2").physics("tds").feature("cdm1").set("Dchem_cB", "1e-5[m^2/s]");
    model.component("comp2").physics("tds").feature("cdm1").set("D_cB", "1e-5[m^2/s]");
    model.component("comp2").physics("tds").feature("reac1").setIndex("R_cA_src", "root.comp2.chem.R_A", 0);
    model.component("comp2").physics("tds").feature("reac1").setIndex("R_cB_src", "root.comp2.chem.R_B", 0);
    model.component("comp2").physics("tds").feature("reac1").set("ReactionHeatSource", "chem");
    model.component("comp2").physics("tds").feature("reac1").set("chemTag", "chem");
    model.component("comp1").physics("re").feature("sync1").set("geomToUse", "geom1");
    model.component("comp1").physics("re").feature("sync1").set("chemTag", "chem");
    model.component("comp1").physics("re").feature("sync1").set("massbalance", "tds");

    model.study("std2").feature("time").setSolveFor("/physics/re", false);
    model.study("std2").feature("time").setSolveFor("/physics/chem", true);
    model.study("std2").feature("time").setSolveFor("/physics/tds", true);
    model.study("std1").feature("param").setSolveFor("/physics/chem", false);
    model.study("std1").feature("param").setSolveFor("/physics/tds", false);
    model.study("std1").feature("time").setSolveFor("/physics/chem", false);
    model.study("std1").feature("time").setSolveFor("/physics/tds", false);

//    In the Model Builder window, expand the Component 2 (comp2) node.
//    Right-click Component 2 (comp2) > Definitions and choose Variables.

    model.component("comp2").variable().create("var1");

    model.component("comp2").geom("geom1").run();

//    In the Settings window for Variables, locate the Variables section.
//    Click Load from File.
//    Browse to the model's Application Library folder and double-click the file cubic_autocatalysis_variables.txt.
//    To import content from file, use:
//    model.component("comp2").variable("var1").loadFile("FILENAME");
    model.component("comp2").variable("var1").set("cA0", "c0*(0.4201+0.2*(sa1+sa2+sb+sc))", "Initial conc. A");
    model.component("comp2").variable("var1").set("cB0", "c0*0.34 - 0.1*cA0", "Initial conc. B");
    model.component("comp2").variable("var1").set("ra", "sqrt((x-0.5)^2+(y-0.5)^2)", "radius a (from center)");
    model.component("comp2").variable("var1")
         .set("rb", "sqrt((x-0.25)^2+(y-0.97)^2)", "radius b (from 1st smaller loci)");
    model.component("comp2").variable("var1")
         .set("rc", "sqrt((x-0.75)^2+(y-0.97)^2)", "radius c (from 2nd smaller loci)");
    model.component("comp2").variable("var1").set("sa1", "exp(-(20*(ra-0.13*l))^4/l^4)", "inner annular front");
    model.component("comp2").variable("var1").set("sa2", "exp(-(20*(ra-0.3*l))^4/l^4)", "outer annular front");
    model.component("comp2").variable("var1").set("sb", "exp(-(20*(rb-0.11*l))^4/l^4)", "satellite b");
    model.component("comp2").variable("var1").set("sc", "exp(-(20*(rc-0.11*l))^4/l^4)", "satellite c");

//    In the Model Builder window, expand the Component 2 (comp2) node.
//    Right-click Component 2 (comp2) > Geometry 1(2D) and choose Square.

    model.component("comp2").geom("geom1").create("sq1", "Square");

//    In the Settings window for Square, locate the Size section.
//    In the Side length text field, type 2*l.

    model.component("comp2").geom("geom1").feature("sq1").set("size", "2*l");

//    Locate the Position section.
//    In the x text field, type -l/2.

    model.component("comp2").geom("geom1").feature("sq1").set("pos", new String[]{"-l/2", "0"});

//    In the y text field, type -l/2.

    model.component("comp2").geom("geom1").feature("sq1").set("pos", new String[]{"-l/2", "-l/2"});
    model.component("comp2").geom("geom1").run();

//    In the Model Builder window, expand the Component 2 (comp2) > Chemistry (chem) node, then click Chemistry (chem).
//    In the Settings window for Chemistry, click to expand the Calculate Transport Properties section.
//    Clear the Calculate mixture properties checkbox.

    model.component("comp2").physics("chem").prop("calcTransport").set("calcTransport", false);

//    In the Model Builder window, under Component 2 (comp2) > Chemistry (chem), click Species: B.
//    In the Settings window for Species, locate the Chemical Formula section.
//    Clear the Enable formula checkbox.
//    In the Model Builder window, expand the Component 2 (comp2) > Transport of Diluted Species (tds) node, then click Initial Values 1.
//    In the Settings window for Initial Values, locate the Initial Values section.
//    In the \[cA\] text field, type cA0.

    model.component("comp2").physics("tds").feature("init1").setIndex("initc", "cA0", 0);

//    In the \[cB\] text field, type cB0.

    model.component("comp2").physics("tds").feature("init1").setIndex("initc", "cB0", 1);

//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp2").physics("tds").create("pc1", "PeriodicCondition", 1);

//    Select Boundaries 2, 3.

    model.component("comp2").physics("tds").feature("pc1").selection().set(2, 3);

//    In the Physics toolbar, click Boundaries and choose Periodic Condition.

    model.component("comp2").physics("tds").create("pc2", "PeriodicCondition", 1);

//    Select Boundaries 1, 4.

    model.component("comp2").physics("tds").feature("pc2").selection().set(1, 4);

//    In the Model Builder window, click Fluid 1.
//    In the Settings window for Fluid, locate the Diffusion section.
//    In the \[D_{\textrm{cA}}\] text field, type DA.

    model.component("comp2").physics("tds").feature("cdm1")
         .set("D_cA", new String[]{"DA", "0", "0", "0", "DA", "0", "0", "0", "DA"});

//    In the \[D_{\textrm{cB}}\] text field, type DB.

    model.component("comp2").physics("tds").feature("cdm1")
         .set("D_cB", new String[]{"DB", "0", "0", "0", "DB", "0", "0", "0", "DB"});

//    In the Mesh toolbar, click Mapped.

    model.component("comp2").mesh("mesh1").create("map1", "Map");

//    Right-click Mapped 1 and choose Distribution.

    model.component("comp2").mesh("mesh1").feature("map1").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Distribution section.
//    In the Number of elements text field, type 200.

    model.component("comp2").mesh("mesh1").feature("map1").feature("dis1").set("numelem", 200);

//    Locate the Boundary Selection section.
//    From the Selection list, select All boundaries.

    model.component("comp2").mesh("mesh1").feature("map1").feature("dis1").selection().all();

//    Click Build All.

    return model;
  }

  public static Model run2(Model model) {

    model.component("comp2").mesh("mesh1").run();

//    In the Study toolbar, click Parametric Sweep.

    model.study("std2").create("param", "Parametric");

//    In the Settings window for Parametric Sweep, locate the Study Settings section.
//    Click Add.

    model.study("std2").feature("param").setIndex("pname", "k", 0);
    model.study("std2").feature("param").setIndex("plistarr", "", 0);
    model.study("std2").feature("param").setIndex("punit", "1/s", 0);
    model.study("std2").feature("param").setIndex("pname", "k", 0);
    model.study("std2").feature("param").setIndex("plistarr", "", 0);
    model.study("std2").feature("param").setIndex("punit", "1/s", 0);

//    In the table, enter the following settings:

    model.study("std2").feature("param").setIndex("plistarr", "0.0609 0.06105 0.0611", 0);
    model.study("std2").feature("param").setIndex("punit", "1/s", 0);

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

    model.study("std2").createAutoSequences("sol");
    model.study("std2").createAutoSequences("jobs");

    model.sol().create("sol15");
    model.sol("sol15").study("std2");
    model.sol("sol15").label("Parametric Solutions 2");

    model.batch("p2").feature("so1").set("psol", "sol15");

    model.result().create("pg2", "PlotGroup2D");
    model.result("pg2").set("data", "dset6");
    model.result("pg2").label("Concentration, A (tds)");
    model.result("pg2").set("titletype", "custom");
    model.result("pg2").set("prefixintitle", "");
    model.result("pg2").set("expressionintitle", false);
    model.result("pg2").set("typeintitle", false);
    model.result("pg2").create("surf1", "Surface");
    model.result("pg2").feature("surf1").set("expr", new String[]{"cA"});
    model.result("pg2").feature("surf1").set("colortable", "Prism");
    model.result("pg2").set("typeintitle", true);
    model.result("pg2").create("arws1", "ArrowSurface");
    model.result("pg2").feature("arws1").set("expr", new String[]{"tds.tflux_cAx", "tds.tflux_cAy"});
    model.result("pg2").feature("arws1").set("xnumber", 10);
    model.result("pg2").feature("arws1").set("ynumber", 10);
    model.result("pg2").feature("arws1").set("color", "black");
    model.result("pg2").feature("arws1").create("sel1", "Selection");
    model.result("pg2").feature("arws1").feature("sel1").selection().set(1);
    model.result().create("pg3", "PlotGroup2D");
    model.result("pg3").set("data", "dset6");
    model.result("pg3").label("Concentration, B (tds)");
    model.result("pg3").set("titletype", "custom");
    model.result("pg3").set("prefixintitle", "");
    model.result("pg3").set("expressionintitle", false);
    model.result("pg3").set("typeintitle", false);
    model.result("pg3").create("surf1", "Surface");
    model.result("pg3").feature("surf1").set("expr", new String[]{"cB"});
    model.result("pg3").feature("surf1").set("colortable", "Prism");
    model.result("pg3").set("typeintitle", true);
    model.result("pg3").create("arws1", "ArrowSurface");
    model.result("pg3").feature("arws1").set("expr", new String[]{"tds.tflux_cBx", "tds.tflux_cBy"});
    model.result("pg3").feature("arws1").set("xnumber", 10);
    model.result("pg3").feature("arws1").set("ynumber", 10);
    model.result("pg3").feature("arws1").set("color", "black");
    model.result("pg3").feature("arws1").create("sel1", "Selection");
    model.result("pg3").feature("arws1").feature("sel1").selection().set(1);
    model.result("pg2").run();
    model.result("pg2").run();

//    In the Model Builder window, expand the Concentration, A (tds) node.
//    Right-click Arrow Surface 1 and choose Delete.

    model.result("pg2").feature().remove("arws1");
    model.result("pg2").run();
    model.result("pg3").run();

//    In the Model Builder window, right-click Concentration, B (tds) and choose Delete.

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

//    In the Model Builder window, under Results, click Concentration, A (tds).
//    In the Settings window for 2D Plot Group, click to expand the Plot Array section.
//    From the Array type list, select Square.

    model.result("pg2").set("plotarraytype", "square");
    model.result("pg2").run();

//    In the Model Builder window, under Results > Concentration, A (tds), click Surface 1.
//    In the Settings window for Surface, type cA in the Label text field.

    model.result("pg2").feature("surf1").label("cA");

//    Click to expand the Plot Array section.
//    Select the Manual indexing checkbox.

    model.result("pg2").feature("surf1").set("manualindexing", true);

//    In the Column index text field, type 1.

    model.result("pg2").feature("surf1").set("colindex", 1);

//    Right-click cA and choose Height Expression.

    model.result("pg2").feature("surf1").create("hght1", "Height");
    model.result("pg2").run();

//    In the Settings window for Height Expression, locate the Axis section.
//    Select the Scale factor checkbox.

    model.result("pg2").feature("surf1").feature("hght1").set("scaleactive", true);

//    In the associated text field, type 1.0.

    model.result("pg2").feature("surf1").feature("hght1").set("scale", "1.0");
    model.result("pg2").run();

//    In the Model Builder window, click cA.
//    In the Settings window for Surface, locate the Coloring and Style section.
//    From the Color table list, select Cividis.

    model.result("pg2").feature("surf1").set("colortable", "Cividis");

//    Right-click cA and choose Duplicate.

    model.result("pg2").feature().duplicate("surf2", "surf1");
    model.result("pg2").run();

//    In the Settings window for Surface, type cB in the Label text field.

    model.result("pg2").feature("surf2").label("cB");

//    Locate the Expression section.
//    In the Expression text field, type cB.

    model.result("pg2").feature("surf2").set("expr", "cB");

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

    model.result("pg2").feature("surf2").set("colortable", "Viridis");

//    Locate the Plot Array section.
//    In the Column index text field, type 0.

    model.result("pg2").feature("surf2").set("colindex", 0);

//    In the Model Builder window, under Study 2, click Step 1: Time Dependent.
//    In the Settings window for Time Dependent, locate the Study Settings section.
//    In the Output times text field, type range(0, 1, 10-1) range(10, 10, 300-10) range(300, 100, 1000-100) range(1e3, 1e3, 2e4-1e3) range(2e4, 2.5e3, 5e4-2.5e3) range(5e4, 1e4, 1e5-1e4) range(1e5, 2.5e4, 6e5).

    model.study("std2").feature("time")
         .set("tlist", "range(0, 1, 10-1) range(10, 10, 300-10) range(300, 100, 1000-100) range(1e3, 1e3, 2e4-1e3) range(2e4, 2.5e3, 5e4-2.5e3) range(5e4, 1e4, 1e5-1e4) range(1e5, 2.5e4, 6e5)");

//    From the Tolerance list, select User controlled.

    model.study("std2").feature("time").set("usertol", true);

//    In the Relative tolerance text field, type 0.001.

    model.study("std2").feature("time").set("rtol", 0.001);

//    Click to expand the Results While Solving section.
//    Select the Plot checkbox.

    model.study("std2").feature("time").set("plot", true);

//    In the table, enter the following settings:

    model.study("std2").feature("time").setIndex("plotgrouparr", "pg2", 0);

//    In the Study toolbar, click Compute.

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

    model.batch("p2").run("compute");

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

//    In the Settings window for 2D Plot Group, click to expand the Title section.
//    From the Title type list, select None.

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

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

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

//    From the Position list, select Alternating.

    model.result("pg2").set("legendpos", "alternating");

//    In the Concentration, A (tds) toolbar, click Animation and choose Player.

    model.result().export().create("anim1", "Animation");
    model.result().export("anim1").set("target", "player");
    model.result().export("anim1").set("plotgroup", "pg2");
    model.result().export("anim1").run();

//    In the Settings window for Animation, locate the Frames section.
//    From the Frame selection list, select All.

    model.result().export("anim1").set("framesel", "all");

//    Click the Play button in the Graphics toolbar.

    model.result().export("anim1").run();

//    Locate the Animation Editing section.
//    From the Parameter value (k (1/s)) list, select 0.06105.

    model.result().export("anim1").setIndex("singlelooplevel", 2, 1);

//    Click the Play button in the Graphics toolbar.

    model.result().export("anim1").run();

    model.title("Cubic Autocatalysis: Exploring the Gray\u2013Scott Model");

    model
         .description("A deceptively simple system of two species and two reactions, describing the autocatalytic conversion of a substance, is shown to display a surprisingly exotic behavior. Starting from a 0D CSTR description, a 2D reaction\u2013diffusion problem is formulated showing rich patterns stemming from the multistability of the underlying reaction network.");

    return model;
  }

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

}
