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.

How to use a global variable in COMSOL model

Please login with a confirmed email address before reporting spam

Dear All,
I am trying to simulate motion of the particle in the fluid channel, The basic idea is to apply a sliding wall boudary condition to make keep the particle stationary in the space. To do this I start with a zero wall sliding velocity (u_wall) and obtain the speed of the particle (uxp1). Later I use this uxp1 to update the velocity of the sliding wall and re-run the model, in the hope of keeping the particles at the centre of the comupational domain. However, I do not know how to incorporate this variable to the FEM model. The following example codes show the details.

Without introducing the global viariable uxp , the following piece of code works well,
...
fem.expr = {'u_wall','0'}
...
bnd.uvw = {'0','u_wall','-u_wall','0','0'};
appl.bnd = bnd;
........Solve the model......
perimeter=mean(postint(fem,'1','unit','m','dl',[5,6,7,8],'edim',1,'solnum','all'));
uxp1=postint(fem,'ut', 'unit','m^2/s', 'dl',[5,6,7,8], 'edim',1, 'solnum','all')/perimeter;
.....

Now I want to feed the the particle speed (uxp1) to the speed of the sliding wall (u_wall)

uxp=0;
while i<10
...
fem.expr = {'u_wall','uxp'}
...
bnd.uvw = {'0','u_wall','-u_wall','0','0'};
appl.bnd = bnd;
........Solve the model......
perimeter=mean(postint(fem,'1','unit','m','dl',[5,6,7,8],'edim',1,'solnum','all'));
uxp1=postint(fem,'ut', 'unit','m^2/s', 'dl',[5,6,7,8], 'edim',1, 'solnum','all')/perimeter;
uxp=uxp+uxp1;
i=i+1
end

This later codes will not run.
Your kind help and guidance are highly appreciated.
Thanks and regards.

0 Replies Last Post Feb 28, 2011, 11:11 a.m. EST
COMSOL Moderator

Hello Zirui Li

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.

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.