Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

particle tracing from the API: controlling and accessing individual particle coordinates

Please login with a confirmed email address before reporting spam

Hello,
I would like to trace charged particles in an electrostatic device using the java API, and
1 - generate the input coordinates and velocities of each individual particle myself
2 - after the tracing has been done, I want to access the coordinates of each individual particle at the output so that I can calculate the transfer properties of the device (the transfer matrix).
Can somebody give a quick hint how this can be done in the API?
Thank you
Daniel

1 Reply Last Post 07.11.2013, 13:07 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.11.2013, 13:07 GMT-5
Well a very stupid solution to access the data is to export the trajectories into a text file and then read them back. But this is quite stupid.
(One needs to export the trajectories with compact=off, otherwise the initial velocities are not written out. However if compact=off, all intermediate points are written out as well, creating a huge file)
[code]
model.result().export().create("plot1", "pg2", "traj1", "Plot");
model.result("pg2").set("window", "graphics");
model.result("pg2").run();
model.result("pg2").set("windowtitle", "");
model.result().export("plot1").set("compact", "off");
model.result().export("plot1") .set("filename", "E:\\Users\\barna\\trajectories.txt");
model.result().export("plot1").run();
[/code]

So something more smart? And how can I control the initial parameters of each particle individually?
Thank you
Daniel
Well a very stupid solution to access the data is to export the trajectories into a text file and then read them back. But this is quite stupid. (One needs to export the trajectories with compact=off, otherwise the initial velocities are not written out. However if compact=off, all intermediate points are written out as well, creating a huge file) [code] model.result().export().create("plot1", "pg2", "traj1", "Plot"); model.result("pg2").set("window", "graphics"); model.result("pg2").run(); model.result("pg2").set("windowtitle", ""); model.result().export("plot1").set("compact", "off"); model.result().export("plot1") .set("filename", "E:\\Users\\barna\\trajectories.txt"); model.result().export("plot1").run(); [/code] So something more smart? And how can I control the initial parameters of each particle individually? Thank you Daniel

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.