/*
 * transmission_line_lpf.java
 */

import com.comsol.model.*;
import com.comsol.model.util.*;

/** Model exported on May 15 2026, 11:32 by COMSOL 6.4.0.421. */
public class transmission_line_lpf {

  public static Model run() {
    Model model = ModelUtil.create("Model");

//    From the File menu, choose New.
//    In the New window, click Model Wizard.
//    In the Model Wizard window, click 2D.
//    In the Select Physics tree, select Radio Frequency > Transmission Line (tl).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Frequency Domain.
//    Click Done.

    model.component().create("comp1", true);

    model.component("comp1").geom().create("geom1", 2);

    model.component("comp1").mesh().create("mesh1");

    model.component("comp1").physics().create("tl", "TransmissionLine", "geom1");

    model.study().create("std1");
    model.study("std1").create("freq", "Frequency");
    model.study("std1").feature("freq").set("solnum", "auto");
    model.study("std1").feature("freq").set("notsolnum", "auto");
    model.study("std1").feature("freq").set("outputmap", new String[]{});
    model.study("std1").feature("freq").set("ngenAUX", "1");
    model.study("std1").feature("freq").set("goalngenAUX", "1");
    model.study("std1").feature("freq").set("ngenAUX", "1");
    model.study("std1").feature("freq").set("goalngenAUX", "1");

//    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 transmission_line_lpf_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("f0", "4[GHz]", "Frequency");
    model.param().set("lda0", "c_const/f0", "Wavelength, free space");
    model.param().set("L0", "250[nH/m]", "Microstrip line inductance");
    model.param().set("C0", "100[pF/m]", "Microstrip line capacitance");
    model.param().set("Z0", "sqrt(L0/C0)", "Characteristic impedance");
    model.param().set("lda0_t", "1/(f0*sqrt(L0*C0))", "Wavelength, transmission line");
    model.param().set("ul", "lda0_t/8", "Unit length");
    model.param().set("z0", "Z0/50[ohm]", "Normalized impedance");
    model.param().set("g1", "1.5963", "Element value1, 0.5dB equal-ripple");
    model.param().set("g2", "1.0967", "Element value2, 0.5dB equal-ripple");
    model.param().set("n_sq", "1+1/g1", "n^2 parameter in Kuroda's identity");
    model.param().set("z1_1", "g1*n_sq", "Normalized transition impedance");
    model.param().set("z1_2", "z0*n_sq", "Open circuit shunt stub1 normalized impedance");
    model.param().set("z2", "1/g2", "Open circuit shunt stub2 normalized impedance");

//    In the Model Builder window, under Component 1 (comp1), click Geometry 1.
//    In the Settings window for Geometry, locate the Units section.
//    From the Length unit list, select mm.

    model.component("comp1").geom("geom1").lengthUnit("mm");

//    In the Geometry toolbar, click More Primitives and choose Line Segment.

    model.component("comp1").geom("geom1").create("ls1", "LineSegment");

//    In the Settings window for Line Segment, locate the Starting Point section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls1").set("specify1", "coord");

//    Locate the Endpoint section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls1").set("specify2", "coord");

//    Locate the Starting Point section.
//    In the x text field, type -ul-0.5.

    model.component("comp1").geom("geom1").feature("ls1").set("coord1", new String[]{"-ul-0.5", "0"});

//    Locate the Endpoint section.
//    In the x text field, type ul+0.5.

    model.component("comp1").geom("geom1").feature("ls1").set("coord2", new String[]{"ul+0.5", "0"});

//    In the Geometry toolbar, click More Primitives and choose Line Segment.

    model.component("comp1").geom("geom1").run("ls1");
    model.component("comp1").geom("geom1").create("ls2", "LineSegment");

//    In the Settings window for Line Segment, locate the Starting Point section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls2").set("specify1", "coord");

//    Locate the Endpoint section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls2").set("specify2", "coord");

//    Locate the Starting Point section.
//    In the x text field, type -ul.

    model.component("comp1").geom("geom1").feature("ls2").set("coord1", new String[]{"-ul", "0"});

//    Locate the Endpoint section.
//    In the x text field, type -ul.

    model.component("comp1").geom("geom1").feature("ls2").set("coord2", new String[]{"-ul", "0"});

//    In the y text field, type ul.

    model.component("comp1").geom("geom1").feature("ls2").set("coord2", new String[]{"-ul", "ul"});

//    In the Geometry toolbar, click More Primitives and choose Line Segment.

    model.component("comp1").geom("geom1").run("ls2");
    model.component("comp1").geom("geom1").create("ls3", "LineSegment");

//    In the Settings window for Line Segment, locate the Starting Point section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls3").set("specify1", "coord");

//    Locate the Endpoint section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls3").set("specify2", "coord");

//    In the y text field, type ul.

    model.component("comp1").geom("geom1").feature("ls3").set("coord2", new String[]{"0", "ul"});

//    In the Geometry toolbar, click More Primitives and choose Line Segment.

    model.component("comp1").geom("geom1").run("ls3");
    model.component("comp1").geom("geom1").create("ls4", "LineSegment");

//    In the Settings window for Line Segment, locate the Starting Point section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls4").set("specify1", "coord");

//    Locate the Endpoint section.
//    From the Specify list, select Coordinates.

    model.component("comp1").geom("geom1").feature("ls4").set("specify2", "coord");

//    Locate the Starting Point section.
//    In the x text field, type ul.

    model.component("comp1").geom("geom1").feature("ls4").set("coord1", new String[]{"ul", "0"});

//    Locate the Endpoint section.
//    In the x text field, type ul.

    model.component("comp1").geom("geom1").feature("ls4").set("coord2", new String[]{"ul", "0"});

//    In the y text field, type ul.

    model.component("comp1").geom("geom1").feature("ls4").set("coord2", new String[]{"ul", "ul"});

//    In the Geometry toolbar, click Build All.

    model.component("comp1").geom("geom1").run("fin");

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Model Builder window, click Geometry 1.
//    In the Physics toolbar, click Points and choose Lumped Port.

    model.component("comp1").physics("tl").create("lport1", "LumpedPort", 0);

//    Select Point 1.

    model.component("comp1").physics("tl").feature("lport1").selection().set(1);

//    In the Settings window for Lumped Port, locate the Port Properties section.
//    From the Wave excitation at this port list, select On.

    model.component("comp1").physics("tl").feature("lport1").set("PortExcitation", "on");

//    In the Physics toolbar, click Points and choose Lumped Port.

    model.component("comp1").physics("tl").create("lport2", "LumpedPort", 0);

//    Select Point 8.

    model.component("comp1").physics("tl").feature("lport2").selection().set(8);

//    Set the input parameters of the transmission line that are configured for 50<symbol>W</symbol>.
//    In the Model Builder window, click Transmission Line Equation 1.
//    In the Settings window for Transmission Line Equation, locate the Transmission Line Parameters section.
//    In the \[L\] text field, type L0.

    model.component("comp1").physics("tl").feature("tle1").set("L", "L0");

//    In the \[C\] text field, type C0.

    model.component("comp1").physics("tl").feature("tle1").set("C", "C0");

//    In the Physics toolbar, click Boundaries and choose Transmission Line Equation.

    model.component("comp1").physics("tl").create("tle2", "TransmissionLineEquation", 1);

//    Select Boundaries 3, 5.

    model.component("comp1").physics("tl").feature("tle2").selection().set(3, 5);

//    In the Settings window for Transmission Line Equation, locate the Transmission Line Parameters section.
//    In the \[L\] text field, type L0*z1_1.

    model.component("comp1").physics("tl").feature("tle2").set("L", "L0*z1_1");

//    In the \[C\] text field, type C0/z1_1.

    model.component("comp1").physics("tl").feature("tle2").set("C", "C0/z1_1");

//    The input parameters are scaled by the normalized impedance for 129.82<symbol>W</symbol>.
//    In the Physics toolbar, click Boundaries and choose Transmission Line Equation.

    model.component("comp1").physics("tl").create("tle3", "TransmissionLineEquation", 1);

//    Select Boundaries 2, 6.

    model.component("comp1").physics("tl").feature("tle3").selection().set(2, 6);

//    In the Settings window for Transmission Line Equation, locate the Transmission Line Parameters section.
//    In the \[L\] text field, type L0*z1_2.

    model.component("comp1").physics("tl").feature("tle3").set("L", "L0*z1_2");

//    In the \[C\] text field, type C0/z1_2.

    model.component("comp1").physics("tl").feature("tle3").set("C", "C0/z1_2");

//    The input parameters are scaled by the normalized impedance for 81.32<symbol>W</symbol>.
//    In the Physics toolbar, click Boundaries and choose Transmission Line Equation.

    model.component("comp1").physics("tl").create("tle4", "TransmissionLineEquation", 1);

//    Select Boundary 4.

    model.component("comp1").physics("tl").feature("tle4").selection().set(4);

//    In the Settings window for Transmission Line Equation, locate the Transmission Line Parameters section.
//    In the \[L\] text field, type L0*z2.

    model.component("comp1").physics("tl").feature("tle4").set("L", "L0*z2");

//    In the \[C\] text field, type C0/z2.

    model.component("comp1").physics("tl").feature("tle4").set("C", "C0/z2");

//    The input parameters are scaled by the normalized impedance for 42.592<symbol>W</symbol>.
//    In the Model Builder window, under Study 1, click Step 1: Frequency Domain.
//    In the Settings window for Frequency Domain, locate the Study Settings section.
//    In the Frequencies text field, type range(1[GHz],0.1[GHz],20[GHz]).

    model.study("std1").feature("freq").set("plist", "range(1[GHz],0.1[GHz],20[GHz])");

//    In the Study toolbar, click Compute.

    model.study("std1").createAutoSequences("all");

    model.sol("sol1").runAll();

    model.result().create("pg1", "PlotGroup2D");
    model.result("pg1").set("showlegendsmaxmin", true);
    model.result("pg1").set("smooth", "internal");
    model.result("pg1").feature().create("line1", "Line");
    model.result("pg1").feature("line1").label("Line Graph");
    model.result("pg1").feature("line1").set("descractive", true);
    model.result("pg1").feature("line1").set("descr", "Electric potential");
    model.result("pg1").feature("line1").set("linetype", "tube");
    model.result("pg1").feature("line1").set("smooth", "internal");
    model.result("pg1").feature("line1").set("data", "parent");
    model.result().create("pg2", "PlotGroup1D");
    model.result("pg2").set("data", "dset1");
    model.result("pg2").create("glob1", "Global");
    model.result("pg2").feature("glob1").set("unit", new String[]{"", ""});
    model.result("pg2").feature("glob1").set("expr", new String[]{"tl.S11dB", "tl.S21dB"});
    model.result("pg2").feature("glob1").set("descr", new String[]{"S11", "S21"});
    model.result("pg2").label("S-Parameter (tl)");
    model.result("pg2").feature("glob1").set("titletype", "none");
    model.result("pg2").feature("glob1").set("xdata", "expr");
    model.result("pg2").set("ylabelactive", true);
    model.result("pg2").set("ylabel", "S-parameter (dB)");
    model.result("pg2").feature("glob1").set("xdataexpr", "freq");
    model.result("pg2").feature("glob1").set("xdataunit", "GHz");
    model.result("pg2").feature("glob1").set("markerpos", "datapoints");
    model.result("pg2").feature("glob1").set("xdatasolnumtype", "all");
    model.result().create("pg3", "SmithGroup");
    model.result("pg3").set("data", "dset1");
    model.result("pg3").create("rgr1", "ReflectionGraph");
    model.result("pg3").feature("rgr1").set("unit", new String[]{""});
    model.result("pg3").feature("rgr1").set("expr", new String[]{"tl.S11"});
    model.result("pg3").feature("rgr1").set("descr", new String[]{"S11"});
    model.result("pg3").label("Smith Plot (tl)");
    model.result("pg3").feature("rgr1").set("titletype", "manual");
    model.result("pg3").feature("rgr1").set("title", "Reflection Graph: S-parameter, Color: Frequency (GHz)");
    model.result("pg3").feature("rgr1").set("linemarker", "point");
    model.result("pg3").feature("rgr1").set("markerpos", "datapoints");
    model.result("pg3").feature("rgr1").create("col1", "Color");
    model.result("pg3").feature("rgr1").feature("col1").set("expr", "tl.freq/1e9");
    model.result("pg3").feature("rgr1").feature("col1").set("colortable", "Spectrum");
    model.result("pg1").run();
    model.result("pg1").run();

//    In the Model Builder window, expand the 2D Plot Group 1 node, then click Line Graph.
//    In the 2D Plot Group 1 toolbar, click Plot.

    model.result("pg1").run();
    model.result("pg1").run();

//    In the Model Builder window, click 2D Plot Group 1.
//    In the Settings window for 2D Plot Group, locate the Data section.
//    From the Parameter value (freq (GHz)) list, select 3.5.

    model.result("pg1").setIndex("looplevel", 26, 0);

//    In the 2D Plot Group 1 toolbar, click Plot.

    model.result("pg1").run();

//    This is the voltage plot at 3.5 GHz that is inside the passband.

    model.result("pg2").run();

//    In the Model Builder window, click S-Parameter (tl).
//    In the Settings window for 1D Plot Group, click to expand the Title section.
//    From the Title type list, select Manual.

    model.result("pg2").set("titletype", "manual");

//    In the Title text area, type 0.5 dB Equal-Ripple Low-Pass Filter, Cutoff at 4GHz.

    model.result("pg2").set("title", "0.5 dB Equal-Ripple Low-Pass Filter, Cutoff at 4GHz");

//    Locate the Axis section.
//    Select the Manual axis limits checkbox.

    model.result("pg2").set("axislimits", true);

//    In the y minimum text field, type -50.

    model.result("pg2").set("ymin", -50);

//    Locate the Legend section.
//    From the Position list, select Lower right.

    model.result("pg2").set("legendpos", "lowerright");

    model.title("Fast Modeling of a Transmission Line Low-Pass Filter");

    model
         .description("One way to design a filter is to use the element values of well-known filter prototypes, such as maximally flat or equal-ripple low-pass filters. It is easier to fabricate a distributed element filter on a microwave substrate than a lumped element filter, since it is cumbersome to find off-the-shelf capacitors and inductors that are exactly matched to the frequency-scaled element values of the filter prototype.\n\nThis tutorial model demonstrates the design process of a distributed element filter using Richard\u2019s transformation, Kuroda\u2019s identity, and the Transmission Line interface. This approach is very fast compared with solving Maxwell\u2019s equations in 3D. The model simulates a three-element 0.5-dB equal-ripple low-pass filter that has a cutoff frequency at 4\u00a0GHz. The resulting S-parameter plot shows a low-pass frequency response that is also periodically observed at a higher frequency range.");

    return model;
  }

  public static void main(String[] args) {
    run();
  }

}
