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.
What is the best way to enter and track 10^5 particles for post-processing?
Posted Mar 4, 2010, 7:50 a.m. EST 6 Replies
Please login with a confirmed email address before reporting spam
I need to release 10^5 particles from random points on the surface of my object, with random energies and directions. I can use MATLAB to build an array of starting points, energies, and directions that are relevant, but don't know how to use that array.
COMSOL 3.5.0.608
MATLAB 2009a
The Help for MATLAB says to start COMSOL with "COMSOL with MATLAB" which I don't see in my Start>Programs menu with the rest of the COMSOL stuff, or on my desktop as the manual suggests.
I tried using File>Client/Server/MATALB>Connect to MATLAB, and I get an error saying that it can't be done. I run MATLAB routinely on my machine...
So I think that if I can connect somehow to MATLAB then I can run as many particles as I wish, but first...how to connect to MATLAB. I suppose? Should I be contacting COMSOL over this?
Thanks for your time...
~Rich~
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
begin
if (Matlab is installed in your local machine) then
if (you are using MS-win)then
go to your comsol\bin folder and look for the file comsol.opts
open this script with a text editor and look for the variable MLROOT
it should be in the beginning of the file.
put to this variable the path of the matlab folder
ex: MLROOT=blabla\blabla\matlab
elseif (you are using Linux OS system) then
go to your comsol/bin/comsol.sh
open this script with a text editor and again look for the variable MLROOT
it should be in the beginning of the file.
put to this variable the path of the matlab folder
ex: MLROOT:=blabla/blabla/matlab
endif
else
re-install your comsol by giving the path of the matlab folder during the installaion.
endif
end
I hope it helps
Cheers
Please login with a confirmed email address before reporting spam
COMSOL was looking for something to which it might append \bin\win32
so I added
mlroot=\Program Files\MATLAB\R2009a\
which launched MATLAB.
MATLAB then generated an error:
??? Undefined function or method 'comsolmexpath' for input arguments of type 'char'.
The saga continues...
~Rich~
Please login with a confirmed email address before reporting spam
once you have the matlab root OK I use:
>> comsol matlab -np 1 -tmpdir /export/home/scratch/$USER
to start "matlab" with the comsol library link loaed and OK, then I type "comsol" in the matlab environment to get my COMSOL GUI, then back and forth wth CNTRL-F and "file import ..."
the "comsol matlab" command is the minimum "-np 1" is to use 1 core, or replace by 8 if you have so many, the "-tempdir ..." is to force comsol to use the local disk for it's scratch file and not to scatter them on others, that in my case are network server directoris.
This is expalined in the installation guide.
Good luck
Ivar
Please login with a confirmed email address before reporting spam
So you have MS-win as OS !!
The path that you have assigned is wrong. This is not the Matlab folder.
Depending on the chosen folder during the Matlab installation your Matlab folder should be in C:\Matlab.. but not
"\Program Files\MATLAB\R2009a\" This is wrong.
Cheers
Please login with a confirmed email address before reporting spam
I have 3 MATLAB versions installed and they are in:
C:\Program Files\MATLAB\R2007a
C:\Program Files\MATLAB\R2008a
C:\Program Files\MATLAB\R2009a
...and they all seem to work OK. I know MATLAB has some peculiar naming conventions, but the installations seem to work OK.
I keep my data in c:\MATLAB\folder...
I removed COMSOL completely and reinstalled it. I pointed it to MATLAB 2007a because the manual I have says that COMSOL won't work with anything later than that. Maybe it will, but the 2007a version is also OK, it seems.
I am able to call MATLAB from the COMSOL UI
File>Client/Server/MALAB>MATLAB
and it works.
I am now trying to accomplish my main goal, that of tracking many particles. So far, I have mixed results. I wrapped a loop around
for i = 0:2
part_loc_x = [0.6+(i*0.02)];
part_loc_y = [0.6+(i*0.02)];
part_loc_z = [0.6+(i*0.02)];
postplot(fem, ...
My first attempt generated the whole plot each time, but only the last particle plotted. So then I tried to execute the original
postplot(fem, ...
followed by a loop to plot just my particles, but I have not found how to do this yet. It seems that I must study each parameter in postplot() and see which ones to use. I would appreciate any feedback here, too.
Many thanks to all of you for your time.
~R~
p.s.
Fortunately, we can edit our posts here. I settled on this to present:
hold on;
for i = 1:5
part_loc_x = [0.6+(rand*0.1)];
part_loc_y = [-0.5+(rand*1.0)];
part_loc_z = [-0.5+(rand*1.0)];
% [part_loc_x part_loc_y part_loc_z]
partvelstart_x = num2str(1e5*rand, '%10.5e\n');
partvelstart_y = num2str(1e5*rand, '%10.5e\n');
partvelstart_z = num2str(1e5*rand, '%10.5e\n');
postplot(fem, ...
'flowdata',{'Ex_es','Ey_es','Ez_es'}, ...
'flowcolor',[1.0,0.0,0.0], ...
'flowlines',30, ...
'flowtype','line', ...
'flowtol',0.01, ...
'flowstattol',0.01, ...
'flowlooptol',0.01, ...
'flowmaxtime',Inf, ...
'flowmaxsteps',5000, ...
'flowback','on', ...
'flownormal','off', ...
'partmasstype','mass', ...
'partplotas','lines', ...
'parttstart','auto', ...
'parttype','line', ...
'partdroptimes','auto', ...
'partstart',{part_loc_x,part_loc_y,part_loc_z}, ...
'partlinecolor',[0.0,0.8,0.8], ...
'partdata',{'-partq*Ex_es','-partq*Ey_es','-partq*Ez_es'}, ...
'partvelstart',{partvelstart_x,partvelstart_y,partvelstart_z}, ...
'partmass','9.1095e-31', ...
'const',{'partq','1.602e-19'}, ...
'partrtol',0.001, ...
'partatol','auto', ...
'parthstart','auto', ...
'parthmax','auto', ...
'partstatictend','auto', ...
'partmaxsteps','auto', ...
'partedgetol',0.001, ...
'partvelvar',{'partu','partv','partw'}, ...
'parttvar','partt', ...
'partstatic','off', ...
'partres',5, ...
'solnum','end', ...
'phase',0, ...
'refine','auto', ...
'geom','on', ...
'geomnum',1, ...
'bdl',{[3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]}, ...
'sdl',{[1]}, ...
'transparency',1.0);
end
hold off;
It may well be that I can eliminate more of these parameters and still get just the plots of the particles.
~R~
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.