/*
 * impedance_matching.java
 */

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

/** Model exported on May 14 2026, 14:58 by COMSOL 6.4.0.420. */
public class impedance_matching {

  public static Model run() {
    Model model = ModelUtil.create("Model");

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    The model is set up in an identical way to the computing plasma impedance model, except an external circuit is used to drive the discharge.
//    In the Model Wizard window, click 1D.
//    In the Select Physics tree, select Plasma > Plasma, Time Periodic (ptp).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select Preset Studies for Selected Physics Interfaces > Time Periodic.
//    Click Done.

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

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

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

    model.component("comp1").physics().create("ptp", "ColdPlasmaTimePeriodic", "geom1");

    model.study().create("std1");
    model.study("std1").create("tper", "TimePeriodic");
    model.study("std1").feature("tper").set("solnum", "auto");
    model.study("std1").feature("tper").set("notsolnum", "auto");
    model.study("std1").feature("tper").set("outputmap", new String[]{});
    model.study("std1").feature("tper").set("ngenAUX", "1");
    model.study("std1").feature("tper").set("ngen", "2");
    model.study("std1").feature("tper").set("goalngenAUX", "1");
    model.study("std1").feature("tper").set("ngenAUX", "1");
    model.study("std1").feature("tper").set("ngen", "2");
    model.study("std1").feature("tper").set("goalngenAUX", "1");

//    Add parameters to compute the match inductance and capacitance.
//    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("L", "0.025[m]");
    model.param().descr("L", "Discharge gap");
    model.param().set("de", "0.3[m]");
    model.param().descr("de", "Electrode diameter");
    model.param().set("As", "0.25*pi*de^2");
    model.param().descr("As", "Electrode area");
    model.param().set("P0", "10[W]");
    model.param().descr("P0", "Input power");
    model.param().set("f0", "13.56E6[Hz]");
    model.param().descr("f0", "Frequency");
    model.param().set("p0", "1[torr]");
    model.param().descr("p0", "Pressure");
    model.param().set("T0", "300[K]");
    model.param().descr("T0", "Temperature");
    model.param().set("Rp", "42.696[ohm]");
    model.param().descr("Rp", "Plasma impedance, real part");
    model.param().set("Xp", "-156.62[ohm]");
    model.param().descr("Xp", "Plasma impedance, imaginary part");
    model.param().set("Rs", "50[ohm]");
    model.param().descr("Rs", "Generator impedance");
    model.param().set("fmatch", "13.56E6[Hz]");
    model.param().descr("fmatch", "Frequency at perfect match");
    model.param().set("Xmd", "sqrt(Rp*Rs-Rp^2)-Xp");
    model.param().descr("Xmd", "Match help variable");
    model.param().set("Bm", "((1/(Rp*Rs))-(1/Rs^2))^0.5");
    model.param().descr("Bm", "Match help variable");
    model.param().set("Lm", "Xmd/(2*pi*fmatch)");
    model.param().descr("Lm", "Inductance");
    model.param().set("Cp", "Bm/(2*pi*fmatch)");
    model.param().descr("Cp", "Capacitance");

//    In the Model Builder window, right-click Component 1 (comp1) > Geometry 1 and choose Interval.

    model.component("comp1").geom("geom1").create("i1", "Interval");

//    In the Settings window for Interval, locate the Interval section.
//    In the table, enter the following settings:

    model.component("comp1").geom("geom1").feature("i1").setIndex("coord", "L", 1);

//    Click Build All Objects.

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

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

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

//    In the Model Builder window, under Component 1 (comp1), click Plasma, Time Periodic (ptp).
//    In the Settings window for Plasma, Time Periodic, locate the Cross-Section Area section.
//    In the \[A\] text field, type As.

    model.component("comp1").physics("ptp").prop("CrossSectionArea").set("A", "As");

//    Locate the Extra Dimension Settings section.
//    In the \[P_{\textrm{xd}}\] text field, type 1/f0.

    model.component("comp1").physics("ptp").prop("ExtraDimensionSettings").set("Period_xd", "1/f0");

//    In the \[N\] text field, type 30.

    model.component("comp1").physics("ptp").prop("ExtraDimensionSettings").set("Nelemptp", 30);

//    Locate the Plasma Properties section.
//    Select the Use reduced electron transport properties checkbox.

    model.component("comp1").physics("ptp").prop("ElectronProperties").set("ReducedProps", true);

//    In the Physics toolbar, click Global and choose Cross Section Import.

    model.component("comp1").physics("ptp").create("xsec1", "CrossSectionImport", -1);

//    In the Settings window for Cross Section Import, locate the Cross Section Import section.
//    Click Browse.
//    Browse to the model's Application Library folder and double-click the file He_xsecs.txt.

    model.component("comp1").physics("ptp").feature("xsec1").set("Filepath", "He_xsecs.txt");

//    Click Import.

    model.component("comp1").physics("ptp").feature("xsec1").runCommand("importData");

//    In the Model Builder window, click Species: He.
//    In the Settings window for Species, locate the Species Formula section.
//    Select the From mass constraint checkbox.

    model.component("comp1").physics("ptp").feature("He").set("FromMassConstraint", true);

//    Locate the General Parameters section.
//    From the Preset species data list, select He.

    model.component("comp1").physics("ptp").feature("He").set("PresetSpeciesData", "He");

//    In the Model Builder window, click Species: Hes.
//    In the Settings window for Species, locate the General Parameters section.
//    From the Preset species data list, select He.

    model.component("comp1").physics("ptp").feature("Hes").set("PresetSpeciesData", "He");

//    In the Model Builder window, click Species: He+.
//    In the Settings window for Species, locate the Species Formula section.
//    Select the Initial value from electroneutrality constraint checkbox.

    model.component("comp1").physics("ptp").feature("He_1p").set("InitIon", true);

//    Locate the General Parameters section.
//    From the Preset species data list, select He.

    model.component("comp1").physics("ptp").feature("He_1p").set("PresetSpeciesData", "He");

//    Locate the Mobility and Diffusivity Expressions section.
//    From the Specification list, select Specify mobility, compute diffusivity.

    model.component("comp1").physics("ptp").feature("He_1p")
         .set("MobilityDiffusivitySpecification", "SpecifyMobilityComputeDiffusivity");

//    From the Ion temperature list, select Use local field approximation.

    model.component("comp1").physics("ptp").feature("He_1p")
         .set("IonTemperatureSpecification", "LocalFieldApproximation");

//    Locate the Mobility Specification section.
//    From the Specify using list, select Helium ion in helium.

    model.component("comp1").physics("ptp").feature("He_1p").set("MobilitySpecification", "HeIoninHe");

//    In the Model Builder window, click Plasma Model 1.
//    In the Settings window for Plasma Model, locate the Model Inputs section.
//    In the \[T\] text field, type T0.

    model.component("comp1").physics("ptp").feature("pes1").set("T", "T0");

//    In the \[p_A\] text field, type p0.

    model.component("comp1").physics("ptp").feature("pes1").set("pA", "p0");

//    In the Physics toolbar, click Boundaries and choose Surface Reaction.

    model.component("comp1").physics("ptp").create("sr1", "SurfaceReaction", 0);

//    In the Settings window for Surface Reaction, locate the Boundary Selection section.
//    From the Selection list, select All boundaries.

    model.component("comp1").physics("ptp").feature("sr1").selection().all();

//    Locate the Reaction Formula section.
//    In the Formula text field, type He+=>He.

    model.component("comp1").physics("ptp").feature("sr1").set("formula", "He+=>He");

//    Locate the Reaction Parameters section.
//    In the \[\gamma_{\textrm{f}}\] text field, type 0.

    model.component("comp1").physics("ptp").feature("sr1").set("gammaf", 0);

//    Locate the Secondary Emission Parameters section.
//    In the \[\gamma_i\] text field, type 0.1.

    model.component("comp1").physics("ptp").feature("sr1").set("gammai", 0.1);

//    In the \[\varepsilon_i\] text field, type 5.8.

    model.component("comp1").physics("ptp").feature("sr1").set("ebari", 5.8);

//    Right-click 1: He+=>He and choose Duplicate.

    model.component("comp1").physics("ptp").feature().duplicate("sr2", "sr1");

//    In the Settings window for Surface Reaction, locate the Reaction Formula section.
//    In the Formula text field, type Hes=>He.

    model.component("comp1").physics("ptp").feature("sr2").set("formula", "Hes=>He");

//    Locate the Reaction Parameters section.
//    In the \[\gamma_{\textrm{f}}\] text field, type 1.

    model.component("comp1").physics("ptp").feature("sr2").set("gammaf", 1);

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

    model.component("comp1").physics("ptp").create("wall1", "WallDriftDiffusion", 0);

//    In the Settings window for Wall, locate the Boundary Selection section.
//    From the Selection list, select All boundaries.

    model.component("comp1").physics("ptp").feature("wall1").selection().all();

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

    model.component("comp1").physics("ptp").create("gnd1", "Ground", 0);

//    Select Boundary 2.

    model.component("comp1").physics("ptp").feature("gnd1").selection().set(2);

//    In the Physics toolbar, click Boundaries and choose Metal Contact.

    model.component("comp1").physics("ptp").create("mct1", "MetalContact", 0);

//    Select Boundary 1.

    model.component("comp1").physics("ptp").feature("mct1").selection().set(1);

//    In the Settings window for Metal Contact, locate the Terminal section.
//    From the Terminal type list, select Circuit.

    model.component("comp1").physics("ptp").feature("mct1").set("TerminalType", "Circuit");

//    From the Circuit type list, select L-network.

    model.component("comp1").physics("ptp").feature("mct1").set("CircuitType", "LNetwork");

//    From the Source type list, select Power source.

    model.component("comp1").physics("ptp").feature("mct1").set("SourceType", "PowerSource");

//    Locate the Circuit Settings section.
//    In the \[P_{\textrm{s}}\] text field, type P0.

    model.component("comp1").physics("ptp").feature("mct1").set("Ps", "P0");

//    In the \[R_s\] text field, type Rs.

    model.component("comp1").physics("ptp").feature("mct1").set("Rs", "Rs");

//    In the \[C_p\] text field, type Cp.

    model.component("comp1").physics("ptp").feature("mct1").set("Cp", "Cp");

//    In the \[L_m\] text field, type Lm.

    model.component("comp1").physics("ptp").feature("mct1").set("Lm", "Lm");

//    In the \[f_p\] text field, type f0.

    model.component("comp1").physics("ptp").feature("mct1").set("fpc", "f0");

//    In the Mesh toolbar, click Edge.

    model.component("comp1").mesh("mesh1").create("edg1", "Edge");

//    Right-click Edge 1 and choose Distribution.

    model.component("comp1").mesh("mesh1").feature("edg1").create("dis1", "Distribution");

//    In the Settings window for Distribution, locate the Distribution section.
//    From the Distribution type list, select Predefined.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("dis1").set("type", "predefined");

//    In the Number of elements text field, type 125.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("dis1").set("elemcount", 125);

//    In the Element ratio text field, type 10.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("dis1").set("elemratio", 10);

//    Select the Symmetric distribution checkbox.

    model.component("comp1").mesh("mesh1").feature("edg1").feature("dis1").set("symmetric", true);

//    Click Build All.

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

//    Since we're not really interested in the spatial distribution of the plasma variables, disable the default plots.
//    In the Model Builder window, click Study 1.
//    In the Settings window for Study, type Power Sweep in the Label text field.

    model.study("std1").label("Power Sweep");

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

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

//    Clear the Generate convergence plots checkbox.

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

//    First, sweep over power.
//    In the Model Builder window, under Power Sweep, click Step 1: Time Periodic.
//    In the Settings window for Time Periodic, click to expand the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

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

//    Click Add.

    model.study("std1").feature("tper").setIndex("pname", "L", 0);
    model.study("std1").feature("tper").setIndex("plistarr", "", 0);
    model.study("std1").feature("tper").setIndex("punit", "m", 0);
    model.study("std1").feature("tper").setIndex("pname", "L", 0);
    model.study("std1").feature("tper").setIndex("plistarr", "", 0);
    model.study("std1").feature("tper").setIndex("punit", "m", 0);

//    In the table, enter the following settings:

    model.study("std1").feature("tper").setIndex("pname", "P0", 0);

//    Click to select the first row in the table.
//    Click Range.
//    In the Range dialog, choose Number of values from the Entry method list.
//    In the Start text field, type 1.
//    In the Stop text field, type 30.
//    In the Number of values text field, type 50.
//    Click Replace.

    model.study("std1").feature("tper").setIndex("plistarr", "range(1,0.5918367346938775,30)", 0);

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

    model.study("std1").feature("tper").setIndex("punit", "W", 0);

//    In the Study toolbar, click Compute.

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

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

//    Add a plot to see how the efficiency changes with power.
//    In the Model Builder window, expand the Results node.
//    Right-click Results and choose 1D Plot Group.

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

//    In the Model Builder window, 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");

//    In the Settings window for Global, click Replace Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Plasma, Time Periodic > Metal Contact 1 > ptp.mct1.alphaP - Maximum power transfer coefficient - 1.

    model.result("pg1").feature("glob1").set("expr", new String[]{"ptp.mct1.alphaP"});
    model.result("pg1").feature("glob1").set("descr", new String[]{"Maximum power transfer coefficient"});
    model.result("pg1").feature("glob1").set("unit", new String[]{"1"});

//    Click Add Expression in the upper-right corner of the y-Axis Data section.
//    From the menu, choose Component 1 (comp1) > Plasma, Time Periodic > Metal Contact 1 > ptp.mct1.etaP - Efficiency - 1.

    model.result("pg1").feature("glob1").set("expr", new String[]{"ptp.mct1.alphaP", "ptp.mct1.etaP"});
    model.result("pg1").feature("glob1")
         .set("descr", new String[]{"Maximum power transfer coefficient", "Efficiency"});

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

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

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

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

//    In the associated text field, type Maximum power transfer efficiency (1) and efficiency (1).

    model.result("pg1").set("ylabel", "Maximum power transfer efficiency (1) and efficiency (1)");

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

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

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

    model.result("pg1").set("legendpos", "lowerright");

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

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

//    In the Label text field, type Power Sweep.

    model.result("pg1").label("Power Sweep");

//    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 > Time Periodic.
//    Click Add Study in the window toolbar.

    model.study().create("std2");
    model.study("std2").create("tper", "TimePeriodic");
    model.study("std2").feature("tper").set("solnum", "auto");
    model.study("std2").feature("tper").set("notsolnum", "auto");
    model.study("std2").feature("tper").set("outputmap", new String[]{});
    model.study("std2").feature("tper").set("ngenAUX", "1");
    model.study("std2").feature("tper").set("ngen", "2");
    model.study("std2").feature("tper").set("goalngenAUX", "1");
    model.study("std2").feature("tper").set("ngenAUX", "1");
    model.study("std2").feature("tper").set("ngen", "2");
    model.study("std2").feature("tper").set("goalngenAUX", "1");

//    In the Home toolbar, click Add Study to close the Add Study window.
//    Now sweep over frequency.
//    In the Settings window for Time Periodic, locate the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

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

//    Click Add.

    model.study("std2").feature("tper").setIndex("pname", "L", 0);
    model.study("std2").feature("tper").setIndex("plistarr", "", 0);
    model.study("std2").feature("tper").setIndex("punit", "m", 0);
    model.study("std2").feature("tper").setIndex("pname", "L", 0);
    model.study("std2").feature("tper").setIndex("plistarr", "", 0);
    model.study("std2").feature("tper").setIndex("punit", "m", 0);

//    In the table, enter the following settings:

    model.study("std2").feature("tper").setIndex("pname", "f0", 0);

//    Click to select the first row in the table.
//    Click Range.
//    In the Range dialog, type 11 in the Start text field.
//    From the Entry method list, select Number of values.
//    In the Stop text field, type 16.
//    In the Number of values text field, type 51.
//    Click Replace.

    model.study("std2").feature("tper").setIndex("plistarr", "range(11,0.1,16)", 0);

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

    model.study("std2").feature("tper").setIndex("punit", "MHz", 0);

//    In the Model Builder window, click Study 2.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate default plots checkbox.

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

//    Clear the Generate convergence plots checkbox.

    model.study("std2").setGenConv(false);

//    In the Label text field, type Frequency Sweep.

    model.study("std2").label("Frequency Sweep");

//    In the Study toolbar, click Compute.

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

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

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

//    In the Model Builder window, right-click Power Sweep and choose Duplicate.

    model.result().duplicate("pg2", "pg1");
    model.result("pg2").run();

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

    model.result("pg2").label("Frequency Sweep");

//    Locate the Data section.
//    From the Dataset list, select Frequency Sweep/Solution 2 (sol2).

    model.result("pg2").set("data", "dset2");
    model.result("pg2").run();

//    Click the Zoom Extents button in the Graphics toolbar.
//    From the Home menu, choose Add Study.
//    Find the Studies subsection.
//    In the Select Study tree, select Preset Studies for Selected Physics Interfaces > Time Periodic.
//    Click Add Study in the window toolbar.

    model.study().create("std3");
    model.study("std3").create("tper", "TimePeriodic");
    model.study("std3").feature("tper").set("solnum", "auto");
    model.study("std3").feature("tper").set("notsolnum", "auto");
    model.study("std3").feature("tper").set("outputmap", new String[]{});
    model.study("std3").feature("tper").set("ngenAUX", "1");
    model.study("std3").feature("tper").set("ngen", "2");
    model.study("std3").feature("tper").set("goalngenAUX", "1");
    model.study("std3").feature("tper").set("ngenAUX", "1");
    model.study("std3").feature("tper").set("ngen", "2");
    model.study("std3").feature("tper").set("goalngenAUX", "1");

//    From the Home menu, choose Add Study.
//    Next, sweep over pressure.
//    In the Settings window for Time Periodic, locate the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

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

//    Click Add.

    model.study("std3").feature("tper").setIndex("pname", "L", 0);
    model.study("std3").feature("tper").setIndex("plistarr", "", 0);
    model.study("std3").feature("tper").setIndex("punit", "m", 0);
    model.study("std3").feature("tper").setIndex("pname", "L", 0);
    model.study("std3").feature("tper").setIndex("plistarr", "", 0);
    model.study("std3").feature("tper").setIndex("punit", "m", 0);

//    In the table, enter the following settings:

    model.study("std3").feature("tper").setIndex("pname", "p0", 0);

//    Click to select the first row in the table.
//    Click Range.
//    In the Range dialog, choose Number of values from the Entry method list.
//    In the Start text field, type 2.
//    In the Stop text field, type 0.4.
//    In the Number of values text field, type 30.
//    Click Replace.

    model.study("std3").feature("tper").setIndex("plistarr", "range(2,-0.055172413793103454,0.4)", 0);

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

    model.study("std3").feature("tper").setIndex("punit", "torr", 0);

//    In the Model Builder window, expand the Frequency Sweep node, then click Study 3.
//    In the Settings window for Study, type Pressure Sweep in the Label text field.

    model.study("std3").label("Pressure Sweep");

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

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

//    Clear the Generate convergence plots checkbox.

    model.study("std3").setGenConv(false);

//    In the Study toolbar, click Compute.

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

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

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

//    In the Model Builder window, right-click Frequency Sweep and choose Duplicate.

    model.result().duplicate("pg3", "pg2");
    model.result("pg3").run();

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

    model.result("pg3").label("Pressure Sweep");

//    Locate the Data section.
//    From the Dataset list, select Pressure Sweep/Solution 3 (sol3).

    model.result("pg3").set("data", "dset3");
    model.result("pg3").run();

//    In the Model Builder window, expand the Pressure Sweep node, then click Global 1.
//    In the Settings window for Global, locate the x-Axis Data section.
//    From the Unit list, select Torr.

    model.result("pg3").feature("glob1").set("xdataparamunit", "Torr");

//    In the Pressure Sweep toolbar, click Plot.

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

//    Finally, change the impedance so that the match occurs at 50 W, then sweep over power once more.
//    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("Rp", "29.175[ohm]");
    model.param().set("Xp", "-126.47[ohm]");

//    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 > Time Periodic.
//    Click Add Study in the window toolbar.

    model.study().create("std4");
    model.study("std4").create("tper", "TimePeriodic");
    model.study("std4").feature("tper").set("solnum", "auto");
    model.study("std4").feature("tper").set("notsolnum", "auto");
    model.study("std4").feature("tper").set("outputmap", new String[]{});
    model.study("std4").feature("tper").set("ngenAUX", "1");
    model.study("std4").feature("tper").set("ngen", "2");
    model.study("std4").feature("tper").set("goalngenAUX", "1");
    model.study("std4").feature("tper").set("ngenAUX", "1");
    model.study("std4").feature("tper").set("ngen", "2");
    model.study("std4").feature("tper").set("goalngenAUX", "1");

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

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

//    Click Add.

    model.study("std4").feature("tper").setIndex("pname", "L", 0);
    model.study("std4").feature("tper").setIndex("plistarr", "", 0);
    model.study("std4").feature("tper").setIndex("punit", "m", 0);
    model.study("std4").feature("tper").setIndex("pname", "L", 0);
    model.study("std4").feature("tper").setIndex("plistarr", "", 0);
    model.study("std4").feature("tper").setIndex("punit", "m", 0);

//    In the table, enter the following settings:

    model.study("std4").feature("tper").setIndex("pname", "P0", 0);

//    Click to select the first row in the table.
//    Click Range.
//    In the Range dialog, choose Number of values from the Entry method list.
//    In the Start text field, type 10.
//    In the Stop text field, type 80.
//    In the Number of values text field, type 51.
//    Click Replace.

    model.study("std4").feature("tper").setIndex("plistarr", "range(10,1.4,80)", 0);

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

    model.study("std4").feature("tper").setIndex("punit", "W", 0);

//    In the Model Builder window, click Study 4.
//    In the Settings window for Study, locate the Study Settings section.
//    Clear the Generate convergence plots checkbox.

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

//    Clear the Generate default plots checkbox.

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

//    In the Label text field, type High Power Sweep.

    model.study("std4").label("High Power Sweep");

//    In the Study toolbar, click Compute.

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

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

//    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, locate the Data section.
//    From the Dataset list, select High Power Sweep/Solution 4 (sol4).

    model.result("pg4").set("data", "dset4");

//    Right-click 1D Plot Group 4 and choose 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 Component 1 (comp1) > Plasma, Time Periodic > Metal Contact 1 > ptp.mct1.alphaP - Maximum power transfer coefficient - 1.

    model.result("pg4").feature("glob1").set("expr", new String[]{"ptp.mct1.alphaP"});
    model.result("pg4").feature("glob1").set("descr", new String[]{"Maximum power transfer coefficient"});
    model.result("pg4").feature("glob1").set("unit", new String[]{"1"});

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

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

//    In the Model Builder window, right-click 1D Plot Group 4 and choose Global.

    model.result("pg4").create("glob2", "Global");
    model.result("pg4").feature("glob2").set("markerpos", "datapoints");
    model.result("pg4").feature("glob2").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 Component 1 (comp1) > Plasma, Time Periodic > Metal Contact 1 > ptp.mct1.etaP - Efficiency - 1.

    model.result("pg4").feature("glob2").set("expr", new String[]{"ptp.mct1.etaP"});
    model.result("pg4").feature("glob2").set("descr", new String[]{"Efficiency"});
    model.result("pg4").feature("glob2").set("unit", new String[]{"1"});
    model.result("pg4").run();

//    In the Model Builder window, under Results, click 1D Plot Group 4.
//    In the Settings window for 1D Plot Group, type High Power Sweep in the Label text field.

    model.result("pg4").label("High Power Sweep");

//    Locate the Plot Settings section.
//    Select the Two y-axes checkbox.

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

//    In the table, enter the following settings:

    model.result("pg4").setIndex("plotonsecyaxis", true, 1, 1);

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

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

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

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

//    In the High Power Sweep toolbar, click Plot.

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

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

    model.title("Impedance Matching");

    model
         .description("This tutorial drives a capacitively coupled plasma with an L-type matching network at high and low powers. At low power, where the harmonics in the current are low, prefect matching is obtained at the chosen power value. Sweeps over power, frequency, and pressure are performed, and their effect on the match power transfer ratio and efficiency are examined. Finally, a sweep is performed over a higher power range, and the presence of sizable harmonics in the current causes an impedance mismatch.");

    return model;
  }

  public static void main(String[] args) {
    run();
  }

}
