Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 5773

Apply physics to each object (Application builder)

$
0
0

Hello, I'm generating a vector of circle objects programmatically (2D), this works well, but I want to apply an acceleration to each generated circle (different in each one).

To apply the acceleration must indicate the indices of the segments of the circle, but when generating it programmatically I do not have them and they are not constant because in each execution the number of circles is changed, how can I obtain those indexes? Is there another solution?

The example code of the loop that generates the circles and tries to apply the acceleration is the following:

// LOOP (N = input value)
for (int i = 0; i < N; ++i) {
  // BUILD CIRCLE i
  String tag = "cloop"+(i+1);
  String pos = "aCol-d/2-d*"+i; // VERTICAL POSITION
  model.component("comp1").geom("geom1").create(tag, "Circle");
  model.component("comp1").geom("geom1").feature(tag).set("pos", new String[]{"0", pos});
  model.component("comp1").geom("geom1").feature(tag).set("r", "a/2");

  // ADD TO ACUMMULATIVE SELECTION FOR DIFFERENCE AFTER THE LOOP
  model.component("comp1").geom("geom1").feature(tag).set("contributeto", "csel1");

 // GET INDEX 
  int[] idx = Unknown(tag); // ??????

  // ACCELERATION
 String atag = "naccloop"+(i+1);
 model.component("comp1").physics("acpr").create(atag, "NormalAcceleration", 1);
 model.component("comp1").physics("acpr").feature(atag).set("nacc", "exp(iniDist*"+i+"/c0 * j*2*pi*frecMax)"); // ACCELERATION VALUE i
 model.component("comp1").physics("acpr").feature(atag).selection().set(idx); // APPLY ACCEL
 }

Thanks!


Viewing all articles
Browse latest Browse all 5773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>