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 Data Extraction

Please login with a confirmed email address before reporting spam

Hi there,

I made a simulation of an electro-kinetic flow within a 2-phase medium, and after computing the currents I wanted to see how particles would behave within the geometry and the resulting fields. I all looked all-right, but what I really need, is a way to extract the particle properties, i.e. for individual particles I want to be able to plot the velocity and the position, as I need to compute the tortuosity.

I tried a great many combinations regarding 1D-plots of individual particles, all of which failed. As a matter of fact everything which one could select from the Charged Particle list failed to result in a plot (besides the global quantities, such as mass and charge, which are steady over the entire domain/time/etc).
I also tried pulling them into Matlab, which again resulted in an errors (of the same kind as the ones in the 1D-plot attempts).

Here is how I tried to extract the data:

q=mpheval(M,{'qx'},'dataset','dset2','complexfun','off','selection','sel1','t',t_list(1:2));

Error using com.comsol.model.impl.NumericalFeatureImpl/getData
Java exception occurred:
Exception:
com.comsol.nativejni.FlNativeException: Failed to evaluate expression
(rethrown as com.comsol.util.exceptions.FlException)
Messages:
Failed to evaluate expression

Undefined post expression

Failed to evaluate variable
- Variable: mod1.qx
- Geometry: 1
- Domain: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Failed to evaluate expression
- Expression: real((999999999.99999988*mod1.qx))

Failed to evaluate expression
- Expression: real(9.999999999999999E8*mod1.qx)

Thanks,
Dan.

3 Replies Last Post 6 févr. 2013, 18:59 UTC−5
Daniel Smith COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 6 févr. 2013, 17:11 UTC−5
Hi, in V4.3 the Particle Evaluation feature under Derived Values was introduced:

www.comsol.com/products/4.3/#particletracing

This allows you to write the numerical value of an expression into a Table for the particles. You can then use the Graph Plot option to plot this data. This means you can plot particle position etc. v.s. time in 1D plots and isolate individual particles. If you want to plot particle position v.s. particle velocity on the same plot you should use a phase portrait. Both are demonstrated in the attached model.

If you want to compute tortuosity for particles you would probably need to add an auxiliary dependent variable and solve an additional ODE for the curvature of the trajectory. This sounds either very difficult or impossible.
Hi, in V4.3 the Particle Evaluation feature under Derived Values was introduced: http://www.comsol.com/products/4.3/#particletracing This allows you to write the numerical value of an expression into a Table for the particles. You can then use the Graph Plot option to plot this data. This means you can plot particle position etc. v.s. time in 1D plots and isolate individual particles. If you want to plot particle position v.s. particle velocity on the same plot you should use a phase portrait. Both are demonstrated in the attached model. If you want to compute tortuosity for particles you would probably need to add an auxiliary dependent variable and solve an additional ODE for the curvature of the trajectory. This sounds either very difficult or impossible.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 6 févr. 2013, 17:31 UTC−5
Thanks!

This seems to be just right!

Why ODE? One can use some simple measures for tortuosity of a material (in 2D), like (mean path length)/(shortest possible path), or some other similar arc-length-dependent measures.

Is there by chance also a Matlab link command which would do a similar thing?

Many thanks again,
Dan.
Thanks! This seems to be just right! Why ODE? One can use some simple measures for tortuosity of a material (in 2D), like (mean path length)/(shortest possible path), or some other similar arc-length-dependent measures. Is there by chance also a Matlab link command which would do a similar thing? Many thanks again, Dan.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 6 févr. 2013, 18:59 UTC−5
Yeah, thanks again for your solution.

Here is the matlab code which will allow you to import the particle associated states in your workspace.

%M=mphload(<your model>)

M.result().numerical.create('par1','Particle')

M.result.table('tbl1').clearTableData();
M.result.numerical('par1').set('expr','qx');
M.result.numerical('par1').setResult();

qx=M.result.table('tbl1').getReal();

M.result.table('tbl1').clearTableData();
M.result.numerical('par1').set('expr','qy');
M.result.numerical('par1').setResult();

qy=M.result.table('tbl1').getReal();
Yeah, thanks again for your solution. Here is the matlab code which will allow you to import the particle associated states in your workspace. %M=mphload() M.result().numerical.create('par1','Particle') M.result.table('tbl1').clearTableData(); M.result.numerical('par1').set('expr','qx'); M.result.numerical('par1').setResult(); qx=M.result.table('tbl1').getReal(); M.result.table('tbl1').clearTableData(); M.result.numerical('par1').set('expr','qy'); M.result.numerical('par1').setResult(); qy=M.result.table('tbl1').getReal();

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.