Advertisement
Guest User

BeamModel

a guest
Dec 13th, 2012
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.56 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package demoguicomsol;
  6.  
  7. import com.comsol.model.*;
  8. import com.comsol.model.util.*;
  9.  
  10.  
  11. /*
  12.  * BeamModel.java
  13.  */
  14.  
  15.  
  16.  
  17. /** Model exported on Dec 13 2012, 02:01 by COMSOL 4.3.0.151. */
  18. public class BeamModel {
  19.  
  20.   public static void main(String[] args) {
  21.     run();
  22.   }
  23.  
  24.   public static Model run() {
  25.     Model model = ModelUtil.create("Model");
  26.  
  27.     model.modelPath("/home/andres/Programs/COMSOL43/demo/api/beammodel");
  28.  
  29.     model.name("BeamModel.mph");
  30.  
  31.     model
  32.          .comments("This model is used to calculate Areas and moment of intertia for a beam. The calculated values can leter be used in a beam model.");
  33.  
  34.     model.baseSystem("mpa");
  35.  
  36.     model.param().set("H", "160[mm]");
  37.     model.param().set("b", "146[mm]");
  38.     model.param().set("tw", "13[mm]");
  39.     model.param().set("tf", "22[mm]");
  40.     model.param().set("r", "12[mm]");
  41.  
  42.     model.modelNode().create("mod1");
  43.  
  44.     model.geom().create("geom1", 2);
  45.     model.geom("geom1").feature().create("r1", "Rectangle");
  46.     model.geom("geom1").feature().create("c1", "Circle");
  47.     model.geom("geom1").feature().create("b1", "BezierPolygon");
  48.     model.geom("geom1").feature().create("dif1", "Difference");
  49.     model.geom("geom1").feature().create("mir1", "Mirror");
  50.     model.geom("geom1").feature().create("mir2", "Mirror");
  51.     model.geom("geom1").feature("r1").set("size", new String[]{"b/2", "H/2"});
  52.     model.geom("geom1").feature("c1")
  53.          .set("pos", new String[]{"tw/2+r", "H/2-tf-r"});
  54.     model.geom("geom1").feature("c1").set("r", "r");
  55.     model.geom("geom1").feature("b1")
  56.          .set("p", new String[][]{{"b/2", "b/2", "tw/2+r", "tw/2", "tw/2", "b/2"}, {"0", "H/2-tf", "H/2-tf", "H/2-tf-r", "0", "0"}});
  57.     model.geom("geom1").feature("b1")
  58.          .set("degree", new String[]{"1", "1", "1", "1", "1"});
  59.     model.geom("geom1").feature("b1")
  60.          .set("w", new String[]{"1", "1", "1", "1", "1", "1", "1", "1", "1", "1"});
  61.     model.geom("geom1").feature("dif1").selection("input")
  62.          .set(new String[]{"r1"});
  63.     model.geom("geom1").feature("dif1").selection("input2")
  64.          .set(new String[]{"b1", "c1"});
  65.     model.geom("geom1").feature("mir1").set("keep", true);
  66.     model.geom("geom1").feature("mir1").set("axis", new String[]{"0", "1"});
  67.     model.geom("geom1").feature("mir1").selection("input")
  68.          .set(new String[]{"dif1"});
  69.     model.geom("geom1").feature("mir2").set("keep", true);
  70.     model.geom("geom1").feature("mir2").selection("input")
  71.          .set(new String[]{"dif1", "mir1"});
  72.     model.geom("geom1").run();
  73.  
  74.     model.variable().create("var1");
  75.     model.variable("var1").model("mod1");
  76.     model.variable("var1").set("A", "intop1(1)");
  77.     model.variable("var1").set("Iy", "intop1(x^2)");
  78.     model.variable("var1").set("Iz", "intop1(y^2)");
  79.     model.variable("var1").set("J", "intop1(2*T)");
  80.  
  81.     model.cpl().create("intop1", "Integration", "geom1");
  82.     model.cpl("intop1").selection().all();
  83.  
  84.     model.physics().create("ht", "HeatTransfer", "geom1");
  85.     model.physics("ht").feature().create("hs1", "HeatSource", 2);
  86.     model.physics("ht").feature("hs1").selection().set(new int[]{1, 2, 3, 4});
  87.     model.physics("ht").feature().create("temp1", "TemperatureBoundary", 1);
  88.     model.physics("ht").feature("temp1").selection()
  89.          .set(new int[]{1, 2, 3, 4, 5, 6, 7, 8, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24});
  90.  
  91.     model.mesh().create("mesh1", "geom1");
  92.     model.mesh("mesh1").feature().create("ftri1", "FreeTri");
  93.  
  94.     model.variable("var1").name("Variables 1a");
  95.  
  96.     model.view("view1").set("showlabels", true);
  97.     model.view("view1").axis().set("xmin", "-103.97526550292969");
  98.     model.view("view1").axis().set("xmax", "103.40934753417969");
  99.     model.view("view1").axis().set("ymin", "-89.1318359375");
  100.     model.view("view1").axis().set("ymax", "86.8681640625");
  101.     model.view("view1").axis().set("xextra", new String[]{});
  102.     model.view("view1").axis().set("yextra", new String[]{});
  103.  
  104.     model.physics("ht").name("Heat Transfer");
  105.     model.physics("ht").prop("PerformanceIndex").set("PerfIndex", "0.5");
  106.     model.physics("ht").feature("solid1").set("k_mat", "userdef");
  107.     model.physics("ht").feature("solid1")
  108.          .set("k", new String[][]{{"1"}, {"0"}, {"0"}, {"0"}, {"1"}, {"0"}, {"0"}, {"0"}, {"1"}});
  109.     model.physics("ht").feature("solid1")
  110.          .set("minput_temperature_src", "root.mod1.T");
  111.     model.physics("ht").feature("hs1").set("Q", "2*1e-3[W/mm^3]");
  112.     model.physics("ht").feature("temp1").set("T0", "0");
  113.  
  114.     model.mesh("mesh1").feature("size").set("hauto", 1);
  115.     model.mesh("mesh1").run();
  116.  
  117.     model.study().create("std1");
  118.     model.study("std1").feature().create("stat", "Stationary");
  119.  
  120.     model.sol().create("sol1");
  121.     model.sol("sol1").study("std1");
  122.     model.sol("sol1").attach("std1");
  123.     model.sol("sol1").feature().create("st1", "StudyStep");
  124.     model.sol("sol1").feature().create("v1", "Variables");
  125.     model.sol("sol1").feature().create("s1", "Stationary");
  126.     model.sol("sol1").feature("s1").feature().create("fc1", "FullyCoupled");
  127.     model.sol("sol1").feature("s1").feature().create("d1", "Direct");
  128.     model.sol("sol1").feature("s1").feature().remove("fcDef");
  129.  
  130.     model.result().dataset().create("int1", "Integral");
  131.     model.result().create("pg1", "PlotGroup2D");
  132.     model.result("pg1").feature().create("surf1", "Surface");
  133.  
  134.     model.sol("sol1").attach("std1");
  135.     model.sol("sol1").feature("st1").name("Compile Equations: Stationary");
  136.     model.sol("sol1").feature("st1").set("studystep", "stat");
  137.     model.sol("sol1").feature("v1").set("control", "stat");
  138.     model.sol("sol1").feature("s1").set("control", "stat");
  139.     model.sol("sol1").feature("s1").feature("fc1").set("initstep", "0.01");
  140.     model.sol("sol1").feature("s1").feature("fc1").set("minstep", "1.0E-6");
  141.     model.sol("sol1").feature("s1").feature("fc1").set("maxiter", "50");
  142.     model.sol("sol1").feature("s1").feature("fc1").set("probesel", "manual");
  143.     model.sol("sol1").feature("s1").feature("d1").set("linsolver", "pardiso");
  144. model.result().numerical().create("glA", "Global");
  145. model.result().numerical("glA").set("expr", "A");
  146. model.result().numerical().create("glIy", "Global");
  147. model.result().numerical("glIy").set("expr", "Iy");
  148. model.result().numerical().create("glIz", "Global");
  149. model.result().numerical("glIz").set("expr", "Iz");
  150. model.result().numerical().create("glJ", "Global");
  151. model.result().numerical("glJ").set("expr", "J");
  152.  
  153.  
  154.     return model;
  155.   }
  156.  
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement