/*
 * membrane_hda.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 15 2026, 11:50 by COMSOL 6.4.0.421. */
public class membrane_hda {

  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 Preset Studies for Selected Physics Interfaces > Stationary Plug Flow.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").physics().create("re", "ReactionEng");

    model.study().create("std1");
    model.study("std1").create("spf", "StationaryPlugflow");
    model.study("std1").feature("spf").set("solnum", "auto");
    model.study("std1").feature("spf").set("notsolnum", "auto");
    model.study("std1").feature("spf").set("outputmap", new String[]{});

//    In this model, a <l>Thermodynamic System</l> will be created from <l>Thermodynamics</l>. The <l>Thermodynamic System</l> includes all thermodynamic properties (such as enthalpy, entropy, etc) which are needed in the simulation of reacting system. The properties from <l>Thermodynamics</l> are coupled to <l>Reaction Engineering</l> automatically.
//    In the Reaction Engineering toolbar, click Thermodynamics and choose Thermodynamic System.
//    First, select a phase state for the Thermodynamic System.
//    Select phases <l>Vapor-liquid</l>.
//    From the Phase list, select Vapor–liquid.
//    Click Next in the window toolbar.
//    Select species hydrogen, methane, benzene, toluene and biphenyl.
//    In the Species list, select hydrogen (1333-74-0, H2).
//    select hydrogen (1333-74-0, H2) in the Species list.
//    Click Add Selected.
//    In the Species list, select methane (74-82-8, CH4).
//    select methane (74-82-8, CH4) in the Species list.
//    Click Add Selected.
//    In the Species list, select benzene (71-43-2, C6H6).
//    select benzene (71-43-2, C6H6) in the Species list.
//    Click Add Selected.
//    In the Species list, select toluene (108-88-3, C7H8).
//    select toluene (108-88-3, C7H8) in the Species list.
//    Click Add Selected.
//    In the Species list, select biphenyl (92-52-4, C12H10).
//    select biphenyl (92-52-4, C12H10) in the Species list.
//    Click Add Selected.
//    Click Next in the window toolbar.
//    Click Finish in the window toolbar.

    model.thermodynamics().feature().create("pp1", "BuiltinPropertyPackage");
    model.thermodynamics().feature("pp1")
         .set("compoundlist", new String[][]{{"hydrogen", "1333-74-0", "H2", "COMSOL"}, 
         {"methane", "74-82-8", "CH4", "COMSOL"}, 
         {"benzene", "71-43-2", "C6H6", "COMSOL"}, 
         {"toluene", "108-88-3", "C7H8", "COMSOL"}, 
         {"biphenyl", "92-52-4", "C12H10", "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("LiquidPhaseModel", "SoaveRedlichKwong");
    model.thermodynamics().feature("pp1").set("LiquidCard", "LiquidPhaseModel");
    model.thermodynamics().feature("pp1").set("EOSModel", "SoaveRedlichKwong");
    model.thermodynamics().feature("pp1").set("GasPhaseModel", "SoaveRedlichKwong");
    model.thermodynamics().feature("pp1").set("GasEOSCard", "GasPhaseModel");
    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", "SoaveRedlichKwong");
    model.thermodynamics().feature("pp1").storePersistenceData();
    model.thermodynamics().feature("pp1").set("WarningState", false);
    model.thermodynamics().feature("pp1").set("Warning", new String[]{""});

//    Create a mixture function for enthalpy of formation to introduce a heat source used later in <l>Reaction Engineering</l>.
//    Right-click Global Definitions > Thermodynamics > Vapor–Liquid System 1 (pp1) and choose Mixture Property.
//    In the list, select Enthalpy of formation (J/mol).
//    select Enthalpy of formation (J/mol) in the list.
//    Click Add Selected.
//    Click Next in the window toolbar.
//    Click Next in the window toolbar.
//    Click Add All.
//    Click Next in the window toolbar.
//    Click Finish in the window toolbar.

    model.thermodynamics().feature("pp1").feature().create("singlephase1", "OnePhaseProperty");
    model.thermodynamics().feature("pp1").feature("singlephase1").label("Enthalpy of formation 1");
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("funcname", "EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("property", "EnthalpyF");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("propertydescr", "Enthalpy of formation");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("unit", "J/mol");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("prop_basis", "mole");
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("compounds", new String[]{"benzene", "biphenyl", "hydrogen", "methane", "toluene"});
    model.thermodynamics().feature("pp1").feature("singlephase1").set("phase", "Vapor");
    model.thermodynamics().feature("pp1").feature("singlephase1").set("comp_basis", "mole");
    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"}, 
         {"molefraction_benzene", "1", "Mole fraction benzene"}, 
         {"molefraction_biphenyl", "1", "Mole fraction biphenyl"}, 
         {"molefraction_hydrogen", "1", "Mole fraction hydrogen"}, 
         {"molefraction_methane", "1", "Mole fraction methane"}, 
         {"molefraction_toluene", "1", "Mole fraction toluene"}});
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("plotargs", new String[][]{{"temperature", "298.15", "373.15"}, 
         {"pressure", "101325", "101325"}, 
         {"molefraction_benzene", "0.2", "0.2"}, 
         {"molefraction_biphenyl", "0.2", "0.2"}, 
         {"molefraction_hydrogen", "0.2", "0.2"}, 
         {"molefraction_methane", "0.2", "0.2"}, 
         {"molefraction_toluene", "0.2", "0.2"}});
    model.thermodynamics().feature("pp1").feature("singlephase1")
         .set("derivatives", new String[]{"EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11_Dtemperature", "EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11_Dpressure", "EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11_Dmolefraction_benzene", "EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11_Dmolefraction_biphenyl", "EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11_Dmolefraction_hydrogen", "EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11_Dmolefraction_methane", "EnthalpyF_benzene_biphenyl_hydrogen_methane_toluene_Vapor11_Dmolefraction_toluene"});
    model.thermodynamics().feature("pp1").feature("singlephase1").set("SecondDerivatives", new String[]{});
    model.thermodynamics().feature("pp1").feature("singlephase1").set("SecondDerivativeIndices", new String[]{});
    model.thermodynamics().feature("pp1").set("WarningState", false);
    model.thermodynamics().feature("pp1").set("Warning", new String[]{""});

//    Change the function name to <c>hF_mixture</c>.
//    In the Settings window for Mixture Property, type hF_mixture in the Function name text field.

    model.thermodynamics().feature("pp1").feature("singlephase1").set("funcname", "hF_mixture");

//    Load model parameters by importing their definitions from a text file.
//    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 membrane_hda_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("T_inlet", "1200[K]", "Inlet temperature");
    model.param().set("p_shell", "2.5*101325[Pa]", "Pressure, shell side");
    model.param().set("p_reactor", "2*101325[Pa]", "Pressure, reactor");
    model.param().set("k", "8.0E-8[m^3/(N*s)]", "Proportionality constant");
    model.param().set("a", "100.5[1/m]", "Area per volume");

//    Add variable definitions from a text file.
//    In the Model Builder window, right-click Component 1 (comp1) > Definitions and choose Variables.

    model.component("comp1").variable().create("var1");

//    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 membrane_hda_variables.txt.
//    To import content from file, use:
//    model.component("comp1").variable("var1").loadFile("FILENAME");
    model.component("comp1").variable("var1")
         .set("f_H2", "k*a*(p_shell-p_reactor)*c_H2_shell", "Membrane mass source");
    model.component("comp1").variable("var1")
         .set("Q_mem", "f_H2*(hF_mixture(T_inlet,p_shell,0,0,1,0,0)-hF_mixture(re.T,p_reactor,0,0,1,0,0))", "Membrane heat source");
    model.component("comp1").variable("var1").set("y_C6H6", "re.F_C6H6/re.F0_C6H5CH3", "Conversion, benzene");
    model.component("comp1").variable("var1")
         .set("c_H2_shell", "p_shell/R_const/re.T", "Hydrogen concentration, membrane side");

//    Note that some expressions use functions in <l>Thermodynamics</l> and variables defined in the <l>Reaction Engineering</l> interface. These variables need to be specified with the scope of the <l>Reaction Engineering</l> node. For example, <c>re.T</c> specifies the temperature variable defined by the <l>Reaction Engineering</l> node with the identifier <c>re</c>.
//    In the Model Builder window, under Component 1 (comp1), click Reaction Engineering (re).
//    In the Settings window for Reaction Engineering, locate the Reactor section.
//    From the Reactor type list, select Plug flow.

    model.component("comp1").physics("re").prop("reactor").set("reactor", "plugflow");

//    Locate the Energy Balance section.
//    From the Energy balance list, select Include.

    model.component("comp1").physics("re").prop("energybalance").set("energybalance", "include");

//    In the \[Q\] text field, type Q_mem.

    model.component("comp1").physics("re").prop("energybalance").set("Qextplug", "Q_mem");

//    This accounts for the heat transferred into the reactor due to the flow across the membrane.
//    Click to expand the Mixture Properties section.
//    In the \[p\] text field, type p_reactor.

    model.component("comp1").physics("re").prop("mixture").set("p", "p_reactor");

//    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 C6H5CH3+H2=>C6H6+CH4.

    model.component("comp1").physics("re").feature("rch1").set("formula", "C6H5CH3+H2=>C6H6+CH4");

//    Locate the Rate Constants section.
//    Select the Use Arrhenius expressions checkbox.

    model.component("comp1").physics("re").feature("rch1").set("useArrhenius", true);

//    In the \[A^{\textrm{f}}\] text field, type 5.67e9[1/s].

    model.component("comp1").physics("re").feature("rch1").set("Af", "5.67e9[1/s]");

//    In the \[E^{\textrm{f}}\] text field, type 228.2e3.

    model.component("comp1").physics("re").feature("rch1").set("Ef", "228.2e3");

//    Locate the Reaction Rate section.
//    From the list, select User defined.

    model.component("comp1").physics("re").feature("rch1").set("ReactionExpression", "UserDefined");

//    Locate the Reaction Orders section.
//    Find the Volumetric overall reaction order subsection.
//    In the Forward text field, type 1.

    model.component("comp1").physics("re").feature("rch1").set("bulkFwdOrder", 1);

//    Locate the Reaction Rate section.
//    In the \[r_{j}\] text field, type re.kf_1*re.c_C6H5CH3*(re.c_H2/1[mol/m^3])^0.5.

    model.component("comp1").physics("re").feature("rch1").set("r", "re.kf_1*re.c_C6H5CH3*(re.c_H2/1[mol/m^3])^0.5");

//    Change the default kinetic expression by modifying the reaction order for hydrogen.
//    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 2C6H6<=>C12H10+H2.

    model.component("comp1").physics("re").feature("rch2").set("formula", "2C6H6<=>C12H10+H2");

//    Locate the Rate Constants section.
//    Select the Use Arrhenius expressions checkbox.

    model.component("comp1").physics("re").feature("rch2").set("useArrhenius", true);

//    In the \[A^{\textrm{f}}\] text field, type 1e8.

    model.component("comp1").physics("re").feature("rch2").set("Af", "1e8");

//    In the \[E^{\textrm{f}}\] text field, type 167.5e3.

    model.component("comp1").physics("re").feature("rch2").set("Ef", "167.5e3");

//    In the \[A^{\textrm{r}}\] text field, type 1e8.

    model.component("comp1").physics("re").feature("rch2").set("Ar", "1e8");

//    In the \[E^{\textrm{r}}\] text field, type 149.8e3.

    model.component("comp1").physics("re").feature("rch2").set("Er", "149.8e3");

//    You will now add an <l>Additional Source</l> feature to <l>Reaction Engineering</l> to the membrane reactor model.
//    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_H2", 4, 0);

//    The <c>f_H2</c> term corresponds to the flow of hydrogen across the membrane.
//    The plug flow reactor requires you to input the inlet molar flow.
//    In the Model Builder window, click Initial Values 1.
//    In the Settings window for Initial Values, locate the General Parameters section.
//    In the \[T_{\textrm{0,in}}\] text field, type T_inlet.

    model.component("comp1").physics("re").feature("inits1").set("T0plug", "T_inlet");

//    Locate the Volumetric Species Initial Values section.
//    In the table, enter the following settings:

    model.component("comp1").physics("re").feature("inits1").setIndex("F0", 10, 1, 0);
    model.component("comp1").physics("re").feature("inits1").setIndex("F0", 10, 4, 0);

//    Couple all species in <l>Reaction Engineering</l> to corresponding species in the created <l>Thermodynamic System</l>. For a coupled species, its thermodynamic properties will be set automatically to the coupled Thermodynamic System. When all species in <l>Reaction Engineering</l> are coupled (fully coupled), the properties of the reacting system (heat capacity, molar volume, etc) will be calculated from the Thermodynamic System.
//    In the Model Builder window, click Reaction Engineering (re).
//    In the Settings window for Reaction Engineering, locate the Mixture Properties section.
//    Select the Thermodynamics checkbox.

    model.component("comp1").physics("re").prop("mixture").set("Thermodynamics", true);

//    Locate the Species Matching section.
//    In the table, enter the following settings:

    model.component("comp1").physics("re").prop("SpeciesMatching").setIndex("PackageSpecies", "biphenyl", 0, 0);
    model.component("comp1").physics("re").prop("SpeciesMatching").setIndex("PackageSpecies", "toluene", 1, 0);
    model.component("comp1").physics("re").prop("SpeciesMatching").setIndex("PackageSpecies", "benzene", 2, 0);
    model.component("comp1").physics("re").prop("SpeciesMatching").setIndex("PackageSpecies", "methane", 3, 0);
    model.component("comp1").physics("re").prop("SpeciesMatching").setIndex("PackageSpecies", "hydrogen", 4, 0);

//    You have now set up a model for a nonisothermal tubular reactor. For the tubular reactor, the <l>Additional Source</l> feature is disabled. First solve this model and review the results, then move on to study the related membrane reactor model with the <l>Additional Source</l> feature.
//    In the present example the total reactor volume is 1 m<sup>3</sup>, so default solver settings can be used.
//    In the Model Builder window, right-click Study 1 and choose Rename.
//    In the Rename Study dialog, type Tubular reactor in the New label text field.
//    Click OK.

    model.study("std1").label("Tubular reactor");

//    In the Model Builder window, under Tubular reactor, click Step 1: Stationary Plug Flow.
//    In the Settings window for Stationary Plug Flow, locate the Physics and Variables Selection section.
//    Select the Modify model configuration for study step checkbox.

    model.study("std1").feature("spf").set("useadvanceddisable", true);

//    In the tree, select Component 1 (comp1) > Reaction Engineering (re) > Additional Source 1.
//    Right-click and choose Disable.

    model.study("std1").feature("spf").set("disabledphysics", new String[]{"re/add1"});

//    In the Model Builder window, click Tubular reactor.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std1").setGenPlots(false);

//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol("sol1").runAll();

//    In the Results toolbar, click 1D Plot Group.

    model.result().create("pg1", "PlotGroup1D");
    model.result("pg1").run();

//    Right-click 1D Plot Group 1 and choose Global.

    model.result("pg1").create("glob1", "Global");
    model.result("pg1").feature("glob1").set("markerpos", "datapoints");
    model.result("pg1").feature("glob1").set("linewidth", "preference");
    model.result("pg1").run();

//    In the Model Builder window, right-click 1D Plot Group 1 and choose Global.

    model.result("pg1").create("glob2", "Global");
    model.result("pg1").feature("glob2").set("markerpos", "datapoints");
    model.result("pg1").feature("glob2").set("linewidth", "preference");
    model.result("pg1").run();

//    In the Settings window for 1D Plot Group, type Concentration and Temperature profile, tubular reactor in the Label text field.

    model.result("pg1").label("Concentration and Temperature profile, tubular reactor");

//    Locate the Plot Settings section.
//    Select the x-axis label checkbox.

    model.result("pg1").set("xlabelactive", true);

//    In the associated text field, type Reactor volume (m<sup>3</sup>).

    model.result("pg1").set("xlabel", "Reactor volume (m<sup>3</sup>)");

//    Select the y-axis label checkbox.

    model.result("pg1").set("ylabelactive", true);

//    In the associated text field, type Concentration (mol/m<sup>3</sup>).

    model.result("pg1").set("ylabel", "Concentration (mol/m<sup>3</sup>)");

//    Select the Two y-axes checkbox.

    model.result("pg1").set("twoyaxes", true);

//    In the table, enter the following settings:

    model.result("pg1").setIndex("plotonsecyaxis", true, 1, 1);

//    Select the Secondary y-axis label checkbox.

    model.result("pg1").set("yseclabelactive", true);

//    In the associated text field, type Temperature (K).

    model.result("pg1").set("yseclabel", "Temperature (K)");
    model.result("pg1").run();

//    In the Model Builder window, under Results > Concentration and Temperature profile, tubular reactor, click Global 1.
//    In the Settings window for Global, type Concentration in the Label text field.

    model.result("pg1").feature("glob1").label("Concentration");

//    Locate the y-Axis Data section.
//    In the table, enter the following settings:

    model.result("pg1").feature("glob1").setIndex("expr", "re.c_C6H5CH3", 0);
    model.result("pg1").feature("glob1").setIndex("expr", "re.c_H2", 1);
    model.result("pg1").feature("glob1").setIndex("expr", "re.c_C6H6", 2);
    model.result("pg1").feature("glob1").setIndex("expr", "re.c_CH4", 3);
    model.result("pg1").feature("glob1").setIndex("expr", "re.c_C12H10", 4);

//    Click to expand the Legends section.
//    From the Legends list, select Manual.

    model.result("pg1").feature("glob1").set("legendmethod", "manual");

//    In the table, enter the following settings:

    model.result("pg1").feature("glob1").setIndex("legends", "Toluene", 0);
    model.result("pg1").feature("glob1").setIndex("legends", "Hydrogen", 1);
    model.result("pg1").feature("glob1").setIndex("legends", "Benzene", 2);
    model.result("pg1").feature("glob1").setIndex("legends", "Methane", 3);
    model.result("pg1").feature("glob1").setIndex("legends", "Biphenyl", 4);

//    Click to expand the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg1").feature("glob1").set("linewidth", 2);
    model.result("pg1").run();

//    In the Model Builder window, under Results > Concentration and Temperature profile, tubular reactor, click Global 2.
//    In the Settings window for Global, type Temperature in the Label text field.

    model.result("pg1").feature("glob2").label("Temperature");

//    Locate the y-Axis Data section.
//    Click Clear Table.

    model.result("pg1").feature("glob2").set("expr", new String[]{});
    model.result("pg1").feature("glob2").set("descr", new String[]{});

//    In the table, enter the following settings:

    model.result("pg1").feature("glob2").setIndex("expr", "re.T", 0);

//    Locate the Coloring and Style section.
//    From the Width list, select 2.

    model.result("pg1").feature("glob2").set("linewidth", 2);

//    Find the Line markers subsection.
//    From the Marker list, select Point.

    model.result("pg1").feature("glob2").set("linemarker", "point");

//    From the Positioning list, select Interpolated.

    model.result("pg1").feature("glob2").set("markerpos", "interp");

//    In the Concentration and Temperature profile, tubular reactor toolbar, click Plot.

    model.result("pg1").run();

//    Click Plot.

    model.result("pg1").run();

//    Locate the Legends section.
//    Find the Include subsection.
//    Select the Label checkbox.

    model.result("pg1").feature("glob2").set("autoplotlabel", true);

//    Clear the Solution checkbox.

    model.result("pg1").feature("glob2").set("autosolution", false);

//    Clear the Expression checkbox.

    model.result("pg1").feature("glob2").set("autoexpr", false);
    model.result("pg1").run();

//    In the Model Builder window, click Concentration and Temperature profile, tubular reactor.
//    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");

//    Locate the Axis section.
//    Select the Manual axis limits checkbox.

    model.result("pg1").set("axislimits", true);

//    In the y maximum text field, type 18.

    model.result("pg1").set("ymax", 18);

//    In the Secondary y maximum text field, type 1370.

    model.result("pg1").set("ymaxsec", 1370);

//    Locate the Legend section.
//    From the Position list, select Upper left.

    model.result("pg1").set("legendpos", "upperleft");

//    In the Concentration and Temperature profile, tubular reactor toolbar, click Plot.

    model.result("pg1").run();

//    In the Home toolbar, click Add Study to open the Add Study window.
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Physics Interfaces > Stationary Plug Flow.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("spf", "StationaryPlugflow");
    model.study("std2").feature("spf").set("solnum", "auto");
    model.study("std2").feature("spf").set("notsolnum", "auto");
    model.study("std2").feature("spf").set("outputmap", new String[]{});

//    In the Home toolbar, click Add Study to close the Add Study window.
//    In the Settings window for Study, type Membrane reactor in the Label text field.

    model.study("std2").label("Membrane reactor");

//    Note: the <l>Additional Source</l> feature is included in membrane reactor model.
//    Locate the Study Settings section.
//    Clear the Generate default plots checkbox.

    model.study("std2").setGenPlots(false);

//    In the Study toolbar, click Compute.

    model.study("std2").createAutoSequences("all");

    model.sol("sol2").runAll();

    model.result("pg1").run();

//    Right-click Concentration and Temperature profile, tubular reactor and choose Duplicate.

    model.result().duplicate("pg2", "pg1");
    model.result("pg2").run();

//    In the Settings window for 1D Plot Group, type Concentration and Temperature profile, membrane reactor in the Label text field.

    model.result("pg2").label("Concentration and Temperature profile,  membrane reactor");

//    Locate the Data section.
//    From the Dataset list, select Membrane reactor/Solution 2 (sol2).

    model.result("pg2").set("data", "dset2");

//    In the Concentration and Temperature profile, membrane reactor toolbar, click Plot.

    model.result("pg2").run();

    model.title("Hydrodealkylation in a Membrane Reactor");

    model
         .description("The thermal hydrodealkylation process carried out in a membrane reactor is modeled in this example. This example uses the Thermodynamics feature to include built-in thermodynamic and physical property evaluations.");

    return model;
  }

  public static void main(String[] args) {
    run();
  }

}
