/*
 * progressive_delamination_in_a_laminated_shell.java
 */

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

/** Model exported on May 11 2026, 10:14 by COMSOL 6.4.0.417. */
public class progressive_delamination_in_a_laminated_shell {

  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 3D.
//    In the Select Physics tree, select Structural Mechanics > Layered Shell (lshell).
//    Click Add.
//    Click Study.
//    In the Select Study tree, select General Studies > Stationary.
//    Click Done.

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

    model.component("comp1").geom().create("geom1", 3);
    model.component("comp1").geom("geom1").geomRep("comsol");

    model.component("comp1").mesh().create("mesh1");
    model.component("comp1").mesh("mesh1").contribute("geom/detail", true);

    model.component("comp1").physics().create("lshell", "LayeredShell", "geom1");

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

//    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 progressive_delamination_in_a_laminated_shell_parameters.txt.
//    To import content from file, use:
//    model.param().loadFile("FILENAME");
    model.param().set("lb", "100[mm]", "Length");
    model.param().set("wb", "50[mm]", "Width");
    model.param().set("hb", "1.5[mm]", "Layer thickness");
    model.param().set("pn", "1e6[N/mm^3]", "Penalty stiffness");
    model.param().set("N_strength", "80[MPa]", "Normal tensile strength");
    model.param().set("S_strength", "100[MPa]", "Shear strength");
    model.param().set("GIc", "0.969[kJ/m^2]", "Mode I critical energy release rate");
    model.param().set("GIIc", "1.719[kJ/m^2]", "Mode II critical energy release rate");
    model.param().set("eta", "2.284", "Exponent of Benzeggagh and Kenane (B-K) criterion");
    model.param().set("Fmax", "28[kN]", "Maximum applied force");
    model.param().set("para", "0", "Load parameter");

//    COMSOL Multiphysics is equipped with built-in material properties for a number of lamina materials. Select the needed materials from the <l>Composites</l> material folder in the built-in material library.
//    In the Materials toolbar, click Add Material to open the Add Material window.
//    In the tree, select Composites > Laminae > Unidirectional fiber lamina: AS4/APC2 carbon/PEEK thermoplastic [fiber volume fraction 50%].
//    Right-click and choose Add to Global Materials.

    model.material().create("mat1", "Common", "");
    model.material("mat1").propertyGroup()
         .create("TransverseIsotropic", "TransverseIsotropic", "Transversely isotropic");
    model.material("mat1")
         .label("Unidirectional fiber lamina: AS4/APC2 carbon/PEEK thermoplastic [fiber volume fraction 50%]");
    model.material("mat1").propertyGroup("def").set("density", "1570[kg/m^3]");
    model.material("mat1").propertyGroup("def")
         .setPropertyInfo("density", "Reference: P.P. Camanho, C.G. Davila, and M.F. De Moura, Numerical Simulation of Mixed Mode Progressive Delamination in Composite Materials, Journal of composite materials, vol. 37, no. 16, 2003.");
    model.material("mat1").propertyGroup("def")
         .set("thermalexpansioncoefficient", new String[]{"-0.2E-6[1/K]", "0", "0", "0", "24E-6[1/K]", "0", "0", "0", "24E-6[1/K]"});
    model.material("mat1").propertyGroup("TransverseIsotropic").set("Evect", new String[]{"122.7[GPa]", "10.1[GPa]"});
    model.material("mat1").propertyGroup("TransverseIsotropic")
         .setPropertyInfo("Evect", "Reference: P.P. Camanho, C.G. Davila, and M.F. De Moura, Numerical Simulation of Mixed Mode Progressive Delamination in Composite Materials, Journal of composite materials, vol. 37, no. 16, 2003.");
    model.material("mat1").propertyGroup("TransverseIsotropic").set("nuvect", new String[]{"0.25", "0.45"});
    model.material("mat1").propertyGroup("TransverseIsotropic")
         .setPropertyInfo("nuvect", "Reference: P.P. Camanho, C.G. Davila, and M.F. De Moura, Numerical Simulation of Mixed Mode Progressive Delamination in Composite Materials, Journal of composite materials, vol. 37, no. 16, 2003.");
    model.material("mat1").propertyGroup("TransverseIsotropic").set("Gvect1", "5.5[GPa]");
    model.material("mat1").propertyGroup("TransverseIsotropic")
         .setPropertyInfo("Gvect1", "Reference: P.P. Camanho, C.G. Davila, and M.F. De Moura, Numerical Simulation of Mixed Mode Progressive Delamination in Composite Materials, Journal of composite materials, vol. 37, no. 16, 2003.");

//    In the Materials toolbar, click Add Material to close the Add Material window.
//    Add a <l>Layered Material</l> node and assign appropriate thickness and rotation angles to each ply.
//    In the Model Builder window, right-click Global Definitions > Materials and choose Layered Material.

    model.material().create("lmat1", "LayeredMaterial", "");

//    In the Settings window for Layered Material, type Layered Material: [0/45] in the Label text field.

    model.material("lmat1").label("Layered Material: [0/45]");

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

    model.material("lmat1").setIndex("rotation", 0, 0);
    model.material("lmat1").setIndex("thickness", "hb", 0);
    model.material("lmat1").setIndex("meshPoints", 1, 0);
    model.material("lmat1").setIndex("tag", "lmat1_1", 0);

//    Click Add.

    model.material("lmat1").setIndex("layername", "Layer 2", 1);
    model.material("lmat1").setIndex("link", "mat1", 1);
    model.material("lmat1").setIndex("rotation", 0, 1);
    model.material("lmat1").setIndex("rotationValue", "\u2013", 1);
    model.material("lmat1").setIndex("thickness", "hb", 1);
    model.material("lmat1").setIndex("meshPoints", 1, 1);
    model.material("lmat1").setIndex("tag", "lmat1_2", 1);
    model.material("lmat1").setIndex("layername", "Layer 2", 1);
    model.material("lmat1").setIndex("link", "mat1", 1);
    model.material("lmat1").setIndex("rotation", 0, 1);
    model.material("lmat1").setIndex("rotationValue", "\u2013", 1);
    model.material("lmat1").setIndex("thickness", "hb", 1);
    model.material("lmat1").setIndex("meshPoints", 1, 1);
    model.material("lmat1").setIndex("tag", "lmat1_2", 1);

//    In the table, enter the following settings:

    model.material("lmat1").setIndex("rotation", 45, 1);
    model.material("lmat1").setIndex("tag", "lmat1_2", 1);

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

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

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

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

    model.component("comp1").variable("var1").set("F", "Fmax*sin(pi*para)");
    model.component("comp1").variable("var1").descr("F", "Applied force");

//    The geometry is in an <eqv>XY</eqv>-plane in which the fibers are oriented with respect to the <eqv>X</eqv> direction. Hence set the first axis of the laminate coordinate system in the <eqv>X</eqv> direction. Also set the frame of <l>Boundary System</l> to reference configuration.
//    In the Model Builder window, click Boundary System 1 (sys1).
//    In the Settings window for Boundary System, locate the Settings section.
//    From the Frame list, select Reference configuration.

    model.component("comp1").coordSystem("sys1").set("frametype", "material");

//    Find the Coordinate names subsection.
//    From the Axis list, select x.

    model.component("comp1").coordSystem("sys1").set("mastercoordsystcomp", "1");

//    In the Geometry toolbar, click Work Plane.

    model.component("comp1").geom("geom1").create("wp1", "WorkPlane");
    model.component("comp1").geom("geom1").feature("wp1").set("unite", true);

//    In the Settings window for Work Plane, click Go to Plane Geometry.
//    In the Model Builder window, click Plane Geometry.
//    In the Work Plane toolbar, click Rectangle.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("r1", "Rectangle");

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

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

//    In the Height text field, type wb.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r1")
         .set("size", new String[]{"lb/2", "wb"});

//    Click Build Selected.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Work Plane toolbar, click Circle.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("c1", "Circle");

//    In the Settings window for Circle, locate the Size and Shape section.
//    In the Radius text field, type lb/10.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("c1").set("r", "lb/10");

//    Locate the Position section.
//    In the xw text field, type lb/5.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("c1").set("pos", new String[]{"lb/5", "0"});

//    In the yw text field, type wb/2.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("c1")
         .set("pos", new String[]{"lb/5", "wb/2"});

//    In the Work Plane toolbar, click Rectangle.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("c1");
    model.component("comp1").geom("geom1").feature("wp1").geom().create("r2", "Rectangle");

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

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

//    In the Height text field, type wb.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("r2")
         .set("size", new String[]{"lb/5", "wb"});

//    Click Build Selected.

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

//    In the Work Plane toolbar, click Transforms and choose Mirror.

    model.component("comp1").geom("geom1").feature("wp1").geom().create("mir1", "Mirror");

//    Click in the Graphics window and then press Ctrl+A to select all objects.

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

//    In the Settings window for Mirror, locate the Input section.
//    Select the Keep input objects checkbox.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("mir1").set("keep", true);

//    Locate the Point on Line of Reflection section.
//    In the xw text field, type lb/2.

    model.component("comp1").geom("geom1").feature("wp1").geom().feature("mir1")
         .set("pos", new String[]{"lb/2", "0"});

//    Click Build Selected.

    model.component("comp1").geom("geom1").feature("wp1").geom().run("mir1");

//    In the Geometry toolbar, click Build All.

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

//    In the Model Builder window, right-click Geometry 1 and choose Virtual Operations > Ignore Edges.

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

//    On the object fin, select Edges 8, 20.

    model.component("comp1").geom("geom1").feature("ige1").selection("input").set("fin", 8, 20);

//    In the Geometry toolbar, click Build All.

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

//    Click the Show Grid button in the Graphics toolbar.

    model.component("comp1").view("view1").set("showgrid", false);

//    Click the Go to Default View button in the Graphics toolbar.
//    In the Model Builder window, right-click Component 1 (comp1) > Materials and choose Layers > Layered Material Link.

    model.component("comp1").material().create("llmat1", "LayeredMaterialLink");

//    For the portion of interface which is initially delaminated, the initial state in <l>Delamination</l> node can be set to <l>Delaminated</l>.
//    In the Physics toolbar, click Boundaries and choose Delamination.

    model.component("comp1").physics("lshell").create("del1", "Delamination", 2);

//    Select Boundaries 2, 5.

    model.component("comp1").physics("lshell").feature("del1").selection().set(2, 5);

//    In the Settings window for Delamination, locate the Initial State section.
//    From the list, select Delaminated.

    model.component("comp1").physics("lshell").feature("del1").set("InitialState", "Delaminated");

//    Locate the Contact section.
//    In the \[p_{\textrm{n}}\] text field, type pn.

    model.component("comp1").physics("lshell").feature("del1").set("pn", "pn");

//    For the portion of interface which is not yet delaminated, the initial state in <l>Delamination</l> node can be set to <l>Bonded</l>. To model contact between delaminated interfaces, the penalty factor is taken same as adhesive stiffness.
//    In the Physics toolbar, click Boundaries and choose Delamination.

    model.component("comp1").physics("lshell").create("del2", "Delamination", 2);

//    Select Boundaries 1, 3, 4, 6.

    model.component("comp1").physics("lshell").feature("del2").selection().set(1, 3, 4, 6);

//    In the Settings window for Delamination, locate the Adhesion section.
//    From the Adhesive stiffness list, select User defined.

    model.component("comp1").physics("lshell").feature("del2").set("StiffnessInput", "UserDefined");

//    Specify the \[\mathbf{k}_{\textrm{A}}\] vector as

    model.component("comp1").physics("lshell").feature("del2").set("kPerArea", new String[]{"pn", "pn", "pn"});

//    Locate the Delamination section.
//    In the \[\sigma_{\textrm{ts}}\] text field, type N_strength.

    model.component("comp1").physics("lshell").feature("del2").set("sigmat", "N_strength");

//    In the \[\sigma_{\textrm{ss}}\] text field, type S_strength.

    model.component("comp1").physics("lshell").feature("del2").set("sigmas", "S_strength");

//    In the \[G_{\textrm{ct}}\] text field, type GIc.

    model.component("comp1").physics("lshell").feature("del2").set("Gct", "GIc");

//    In the \[G_{\textrm{cs}}\] text field, type GIIc.

    model.component("comp1").physics("lshell").feature("del2").set("Gcs", "GIIc");

//    From the Mixed mode criterion list, select Benzeggagh–Kenane.

    model.component("comp1").physics("lshell").feature("del2").set("FailureCriterion", "BK");

//    In the \[\alpha\] text field, type eta.

    model.component("comp1").physics("lshell").feature("del2").set("alpha", "eta");

//    Locate the Contact section.
//    From the Penalty factor list, select From adhesive stiffness.

    model.component("comp1").physics("lshell").feature("del2").set("PenaltyFactor", "FromAdhesiveStiffness");

//    In the Physics toolbar, click Edges and choose Fixed Constraint.

    model.component("comp1").physics("lshell").create("fix1", "Fixed", 1);

//    Select Edges 1, 23.

    model.component("comp1").physics("lshell").feature("fix1").selection().set(1, 23);

//    In the Physics toolbar, click Boundaries and choose Face Load.

    model.component("comp1").physics("lshell").create("fl1", "FaceLoad", 2);

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

    model.component("comp1").physics("lshell").feature("fl1").selection().all();

//    Locate the Interface Selection section.
//    From the Apply to list, select Top interface.

    model.component("comp1").physics("lshell").feature("fl1").set("applyTo", "top");

//    Locate the Force section.
//    From the Load type list, select Total force.

    model.component("comp1").physics("lshell").feature("fl1").set("forceType", "TotalForce");

//    Specify the \[\mathbf{F}_{\mathrm{tot}}\] vector as

    model.component("comp1").physics("lshell").feature("fl1").set("force", new String[]{"0", "0", "-F"});

//    In the Mesh toolbar, click More Generators and choose Mapped.

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

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

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

//    Right-click Mapped 1 and choose Distribution.

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

//    Select Edges 4, 5, 6, 8, 9, 10, 15, 16, 17, 19, 20, 21.

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").selection()
         .set(4, 5, 6, 8, 9, 10, 15, 16, 17, 19, 20, 21);

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

    model.component("comp1").mesh("mesh1").feature("map1").feature("dis1").set("numelem", 25);

//    In the Model Builder window, right-click Mesh 1 and choose Build All.

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

//    In the Model Builder window, under Study 1, click Step 1: Stationary.
//    In the Settings window for Stationary, locate the Study Settings section.
//    Select the Include geometric nonlinearity checkbox.

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

//    Click to expand the Study Extensions section.
//    Select the Auxiliary sweep checkbox.

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

//    Click Add.

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

//    In the table, enter the following settings:

    model.study("std1").feature("stat").setIndex("pname", "para", 0);
    model.study("std1").feature("stat").setIndex("plistarr", "range(0,0.025,0.5) range(0.55,0.05,1)", 0);
    model.study("std1").feature("stat").setIndex("punit", "", 0);

//    In the table, click to select the cell at row number 1 and column number 3.
//    In the Study toolbar, click Show Default Solver.

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

//    In the Model Builder window, expand the Solution 1 (sol1) node.
//    Switch to an undamped Newton method.
//    In the Model Builder window, expand the Study 1 > Solver Configurations > Solution 1 (sol1) > Stationary Solver 1 node, then click Fully Coupled 1.
//    In the Settings window for Fully Coupled, click to expand the Method and Termination section.
//    From the Nonlinear method list, select Constant (Newton).

    model.sol("sol1").feature("s1").feature("fc1").set("dtech", "const");

//    In the Study toolbar, click Compute.

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

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

    model.result().dataset().create("dset1lshelllshl", "LayeredMaterial");
    model.result().dataset("dset1lshelllshl").set("data", "dset1");
    model.result().create("pg1", "PlotGroup3D");
    model.result("pg1").set("data", "dset1lshelllshl");
    model.result("pg1").setIndex("looplevel", 31, 0);
    model.result("pg1").label("Stress (lshell)");
    model.result("pg1").set("showlegends", true);
    model.result("pg1").create("surf1", "Surface");
    model.result("pg1").feature("surf1").set("expr", new String[]{"lshell.sllGp11"});
    model.result("pg1").feature("surf1").set("threshold", "manual");
    model.result("pg1").feature("surf1").set("thresholdvalue", 0.2);
    model.result("pg1").feature("surf1").set("colortable", "Rainbow");
    model.result("pg1").feature("surf1").set("colortabletrans", "none");
    model.result("pg1").feature("surf1").set("colorscalemode", "linear");
    model.result("pg1").feature("surf1").set("descractive", true);
    model.result("pg1").feature("surf1").set("descr", "Stress tensor, layer coordinate system, 11-component");
    model.result("pg1").feature("surf1").set("descractive", false);
    model.result("pg1").feature("surf1").set("colortable", "Prism");
    model.result("pg1").feature("surf1").create("def", "Deform");
    model.result("pg1").feature("surf1").feature("def").set("scaleactive", true);
    model.result("pg1").feature("surf1").feature("def").set("scale", "1");
    model.result("pg1").feature("surf1").feature("def").set("expr", new String[]{"u", "v", "w"});
    model.result("pg1").feature("surf1").feature("def")
         .set("descr", "Displacement field (material and geometry frames)");
    model.result("pg1").run();

//    Set default units for result presentation.
//    In the Results toolbar, click Configurations and choose Preferred Units.

    model.result().configuration().create("prfu1", "PreferredUnits");

//    In the Settings window for Preferred Units, locate the Units section.
//    Click Add Physical Quantity.
//    In the Physical Quantity dialog, select Solid Mechanics > Stress tensor (N/m^2) in the tree.
//    Click OK.

    model.result().configuration("prfu1")
         .setIndex("quantityunits", new String[]{"stress", "Stress tensor", "N/m^2", "N/m^2"}, 0);

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

    model.result().configuration("prfu1").setIndex("quantityunits", "MPa", 0, 3);

//    Select the Apply conversions to expressions with the same dimensions checkbox.

    model.result().configuration("prfu1").set("applytosamedims", true);

//    Click Apply.

    model.result().configuration("prfu1").apply();
    model.result("pg1").run();

//    In the Model Builder window, under Results, click Stress (lshell).
//    In the Settings window for 3D Plot Group, locate the Data section.
//    From the Parameter value (para) list, select 0.5.

    model.result("pg1").setIndex("looplevel", 21, 0);

//    Locate the Color Legend section.
//    Select the Show maximum and minimum values checkbox.

    model.result("pg1").set("showlegendsmaxmin", true);
    model.result("pg1").run();

//    In the Model Builder window, expand the Stress (lshell) node, then click Surface 1.
//    In the Settings window for Surface, click to expand the Range section.
//    Select the Manual color range checkbox.

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

//    In the Minimum text field, type -2e3.

    model.result("pg1").feature("surf1").set("rangecolormin", "-2e3");

//    In the Maximum text field, type 3e3.

    model.result("pg1").feature("surf1").set("rangecolormax", "3e3");
    model.result("pg1").run();

//    In the Model Builder window, collapse the Results > Stress (lshell) node.

    model.component("comp1").view("view1").set("showgrid", true);

//    In the Model Builder window, right-click the root node and choose Plot.
//    In the Results toolbar, click Result Templates to open the Result Templates window.
//    In the tree, select Study 1/Solution 1 (sol1) > Layered Shell > Stress, Slice (lshell).
//    Click Add Result Template in the window toolbar.

    model.result().create("pg2", "PlotGroup3D");
    model.result("pg2").set("data", "dset1");
    model.result("pg2").setIndex("looplevel", 31, 0);
    model.result("pg2").label("Stress, Slice (lshell)");
    model.result("pg2").set("showlegends", true);
    model.result("pg2").create("lss1", "LayeredMaterialSlice");
    model.result("pg2").feature("lss1").set("expr", new String[]{"lshell.sllGp11"});
    model.result("pg2").feature("lss1").set("threshold", "manual");
    model.result("pg2").feature("lss1").set("thresholdvalue", 0.2);
    model.result("pg2").feature("lss1").set("colortable", "Prism");
    model.result("pg2").feature("lss1").set("colortabletrans", "none");
    model.result("pg2").feature("lss1").set("colorscalemode", "linear");
    model.result("pg2").feature("lss1").set("descractive", false);
    model.result("pg2").feature("lss1").set("descr", "Stress tensor, layer coordinate system, 11-component");
    model.result("pg2").feature("lss1").set("locdef", "relative");
    model.result("pg2").feature("lss1").set("localzrel", "lshell.z");
    model.result("pg2").feature("lss1").create("def", "Deform");
    model.result("pg2").feature("lss1").feature("def").set("scaleactive", true);
    model.result("pg2").feature("lss1").feature("def").set("scale", "1");
    model.result("pg2").feature("lss1").feature("def").set("expr", new String[]{"u", "v", "w"});
    model.result("pg2").feature("lss1").feature("def")
         .set("descr", "Displacement field (material and geometry frames)");
    model.result("pg2").label("Stress, Slice (lshell)");
    model.result("pg2").run();

//    In the Results toolbar, click Result Templates to close the Result Templates window.
//    In the Settings window for 3D Plot Group, locate the Data section.
//    From the Parameter value (para) list, select 0.5.

    model.result("pg2").setIndex("looplevel", 21, 0);

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

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

//    Locate the Color Legend section.
//    Select the Show maximum and minimum values checkbox.

    model.result("pg2").set("showlegendsmaxmin", true);
    model.result("pg2").run();

//    In the Model Builder window, expand the Stress, Slice (lshell) node, then click Layered Material Slice 1.
//    In the Settings window for Layered Material Slice, locate the Through-Thickness Location section.
//    From the Location definition list, select Layer midplanes.

    model.result("pg2").feature("lss1").set("locdef", "layermidplanes");

//    Locate the Layout section.
//    From the Displacement list, select Linear.

    model.result("pg2").feature("lss1").set("slicedisplacement", "linear");

//    From the Orientation list, select y.

    model.result("pg2").feature("lss1").set("orientationlinear", "y");

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

    model.result("pg2").feature("lss1").set("rangecoloractive", true);

//    In the Minimum text field, type -1e2.

    model.result("pg2").feature("lss1").set("rangecolormin", "-1e2");

//    In the Maximum text field, type 1e3.

    model.result("pg2").feature("lss1").set("rangecolormax", "1e3");
    model.result("pg2").run();

//    In the Model Builder window, click Stress, Slice (lshell).
//    In the Settings window for 3D Plot Group, locate the Plot Settings section.
//    From the View list, select New view.

    model.result("pg2").set("view", "new");

//    In the Stress, Slice (lshell) toolbar, click Plot.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Results toolbar, click 3D Plot Group.

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

//    In the Settings window for 3D Plot Group, type Interface Health, 100% Damaged in the Label text field.

    model.result("pg3").label("Interface Health, 100% Damaged");

//    Locate the Data section.
//    From the Parameter value (para) list, select 0.5.

    model.result("pg3").setIndex("looplevel", 21, 0);

//    Locate the Plot Settings section.
//    From the Frame list, select Spatial (x, y, z).

    model.result("pg3").set("frametype", "spatial");

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

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

//    In the Interface Health, 100% Damaged toolbar, click More Plots and choose Layered Material Slice.

    model.result("pg3").create("lss1", "LayeredMaterialSlice");
    model.result("pg3").feature("lss1").set("evaluationsettings", "parent");

//    In the Settings window for Layered Material Slice, locate the Expression section.
//    In the Expression text field, type lshell.idmg.

    model.result("pg3").feature("lss1").set("expr", "lshell.idmg");

//    Locate the Through-Thickness Location section.
//    From the Location definition list, select Interfaces.

    model.result("pg3").feature("lss1").set("locdef", "interfaces");

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

    model.result("pg3").feature("lss1").set("colortable", "Traffic");

//    Right-click Layered Material Slice 1 and choose Deformation.

    model.result("pg3").feature("lss1").create("def1", "Deform");
    model.result("pg3").run();

//    In the Settings window for Deformation, locate the Scale section.
//    Select the Scale factor checkbox.

    model.result("pg3").feature("lss1").feature("def1").set("scaleactive", true);

//    In the associated text field, type 1.

    model.result("pg3").feature("lss1").feature("def1").set("scale", 1);

//    In the Interface Health, 100% Damaged toolbar, click Plot.

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

//    Click the Zoom Extents button in the Graphics toolbar.
//    In the Results toolbar, click 3D Plot Group.

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

//    In the Settings window for 3D Plot Group, type Adhesive Stress, t1 Direction in the Label text field.

    model.result("pg4").label("Adhesive Stress, t1 Direction");

//    Locate the Data section.
//    From the Parameter value (para) list, select 0.5.

    model.result("pg4").setIndex("looplevel", 21, 0);

//    Locate the Plot Settings section.
//    From the Frame list, select Spatial (x, y, z).

    model.result("pg4").set("frametype", "spatial");

//    In the Adhesive Stress, t1 Direction toolbar, click More Plots and choose Layered Material Slice.

    model.result("pg4").create("lss1", "LayeredMaterialSlice");
    model.result("pg4").feature("lss1").set("evaluationsettings", "parent");

//    In the Settings window for Layered Material Slice, click Replace Expression in the upper-right corner of the Expression section.
//    From the menu, choose Component 1 (comp1) > Layered Shell > Delamination > Adhesive stress (spatial frame) - N/m² > lshell.fst1 - Adhesive stress, t1-component.

    model.result("pg4").feature("lss1").set("expr", "lshell.fst1");
    model.result("pg4").feature("lss1").set("descr", "Adhesive stress, t1-component");

//    Locate the Through-Thickness Location section.
//    From the Location definition list, select Interfaces.

    model.result("pg4").feature("lss1").set("locdef", "interfaces");

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

    model.result("pg4").feature("lss1").set("colortable", "RainbowLight");

//    From the Scale list, select Linear symmetric.

    model.result("pg4").feature("lss1").set("colorscalemode", "linearsymmetric");

//    Right-click Layered Material Slice 1 and choose Deformation.

    model.result("pg4").feature("lss1").create("def1", "Deform");
    model.result("pg4").run();

//    In the Settings window for Deformation, locate the Scale section.
//    Select the Scale factor checkbox.

    model.result("pg4").feature("lss1").feature("def1").set("scaleactive", true);

//    In the associated text field, type 1.

    model.result("pg4").feature("lss1").feature("def1").set("scale", 1);
    model.result("pg4").run();

//    In the Model Builder window, under Results, click Adhesive Stress, t1 Direction.
//    In the Adhesive Stress, t1 Direction toolbar, click Plot.

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

//    In the Results toolbar, click More Datasets and choose Layered Material.

    model.result().dataset().create("lshl1", "LayeredMaterial");

//    In the Settings window for Layered Material, type Layered Material (Interfaces) in the Label text field.

    model.result().dataset("lshl1").label("Layered Material (Interfaces)");

//    Locate the Layers section.
//    From the Evaluate in list, select Interfaces.

    model.result().dataset("lshl1").set("evaluatein", "interfaces");

//    In the Results toolbar, click Evaluation Group.

    model.result().evaluationGroup().create("eg1", "EvaluationGroup");

    return model;
  }

  public static Model run2(Model model) {

//    In the Settings window for Evaluation Group, type Damaged Area in the Label text field.

    model.result().evaluationGroup("eg1").label("Damaged Area");

//    Locate the Data section.
//    From the Dataset list, select Layered Material (Interfaces).

    model.result().evaluationGroup("eg1").set("data", "lshl1");

//    Right-click Damaged Area and choose Integration > Surface Integration.

    model.result().evaluationGroup("eg1").create("int1", "IntSurface");
    model.result().evaluationGroup("eg1").feature("int1").set("intvolume", true);

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

    model.result().evaluationGroup("eg1").feature("int1").selection().all();

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

    model.result().evaluationGroup("eg1").feature("int1").setIndex("expr", "gpeval(4,lshell.idmg)/(lb*wb)", 0);
    model.result().evaluationGroup("eg1").feature("int1").setIndex("unit", "%", 0);
    model.result().evaluationGroup("eg1").feature("int1").setIndex("descr", "Damage area", 0);

//    In the Damaged Area toolbar, click Evaluate.

    model.result().evaluationGroup("eg1").run();

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

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

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

    model.result("pg5").label("Load vs. Damage");

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

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

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

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

//    In the associated text field, type para (1).

    model.result("pg5").set("xlabel", "para (1)");

//    Select the y-axis label checkbox.

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

//    In the associated text field, type Total damage area (%).

    model.result("pg5").set("ylabel", "Total damage area (%)");

//    Select the Two y-axes checkbox.

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

//    Click to collapse the Axis section.
//    Locate the Legend section.
//    From the Position list, select Lower middle.

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

//    Right-click Load vs. Damage and choose Table Graph.

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

//    In the Settings window for Table Graph, locate the Data section.
//    From the Source list, select Evaluation group.

    model.result("pg5").feature("tblp1").set("source", "evaluationgroup");

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

    model.result("pg5").feature("tblp1").set("legend", true);
    model.result("pg5").run();

//    In the Model Builder window, right-click Load vs. Damage and choose Global.

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

//    In the Settings window for Global, locate the Data section.
//    From the Dataset list, select Study 1/Solution 1 (sol1).

    model.result("pg5").feature("glob1").set("data", "dset1");

//    Locate the y-Axis section.
//    Select the Plot on secondary y-axis checkbox.

    model.result("pg5").feature("glob1").set("plotonsecyaxis", true);

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

    model.result("pg5").feature("glob1").setIndex("expr", "F", 0);
    model.result("pg5").feature("glob1").setIndex("unit", "kN", 0);
    model.result("pg5").feature("glob1").setIndex("descr", "Applied force", 0);
    model.result("pg5").run();

//    In the Model Builder window, collapse the Results > Load vs. Damage node.
//    In the Model Builder window, click Load vs. Damage.
//    In the Load vs. Damage toolbar, click Plot.

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

//    In the Results toolbar, click Animation and choose Player.

    model.result().export().create("anim1", "Animation");
    model.result().export("anim1").set("target", "player");
    model.result().export("anim1").set("fontsize", "9");
    model.result().export("anim1").set("colortheme", "globaltheme");
    model.result().export("anim1").set("customcolor", new double[]{1, 1, 1});
    model.result().export("anim1").set("background", "color");
    model.result().export("anim1").set("gltfincludelines", "on");
    model.result().export("anim1").set("title1d", "on");
    model.result().export("anim1").set("legend1d", "on");
    model.result().export("anim1").set("logo1d", "on");
    model.result().export("anim1").set("options1d", "on");
    model.result().export("anim1").set("title2d", "on");
    model.result().export("anim1").set("legend2d", "on");
    model.result().export("anim1").set("logo2d", "on");
    model.result().export("anim1").set("options2d", "off");
    model.result().export("anim1").set("title3d", "on");
    model.result().export("anim1").set("legend3d", "on");
    model.result().export("anim1").set("logo3d", "on");
    model.result().export("anim1").set("options3d", "off");
    model.result().export("anim1").set("axisorientation", "on");
    model.result().export("anim1").set("grid", "on");
    model.result().export("anim1").set("axes1d", "on");
    model.result().export("anim1").set("axes2d", "on");
    model.result().export("anim1").set("showgrid", "on");
    model.result().export("anim1").showFrame();

//    In the Settings window for Animation, type Animation: Stress in the Label text field.

    model.result().export("anim1").label("Animation: Stress");

//    Locate the Frames section.
//    From the Frame selection list, select All.

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

//    Locate the Playing section.
//    In the Display each frame for text field, type 0.3.

    model.result().export("anim1").set("frametime", 0.3);

//    Right-click Animation: Stress and choose Duplicate.

    model.result().export().duplicate("anim2", "anim1");
    model.result().export("anim2").showFrame();

//    In the Settings window for Animation, type Animation: Interface Health in the Label text field.

    model.result().export("anim2").label("Animation: Interface Health");

//    Locate the Scene section.
//    From the Subject list, select Interface Health, 100% Damaged.

    model.result().export("anim2").set("plotgroup", "pg3");

//    Right-click Animation: Interface Health and choose Duplicate.

    model.result().export().duplicate("anim3", "anim2");
    model.result().export("anim3").showFrame();

//    In the Settings window for Animation, type Animation: Adhesive Stress in the Label text field.

    model.result().export("anim3").label("Animation: Adhesive Stress");

//    Locate the Scene section.
//    From the Subject list, select Adhesive Stress, t1 Direction.

    model.result().export("anim3").set("plotgroup", "pg4");
    model.result("pg3").run();

    model.title("Progressive Delamination in a Laminated Shell");

    model
         .description("Interfacial failure or delamination in a composite material is a common phenomenon. This can be simulated using Cohesive Zone Model (CZM).\n\nThis example shows the implementation of a CZM with a bilinear traction-separation law in the Layered Shell interface. It is used to predict the mixed-mode softening onset and delamination propagation.");

    return model;
  }

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

}
