Including Operators and Expressions in a Multiphysics Simulation is Easier Than you Think
Linus Andersson | December 11, 2009
As most skilled COMSOL users, I am sure you know that you are not limited to just selecting what is in our drop-down lists. Say that you have invented your own measure of structural stress. You want it to be equal to the quadratic mean of the Tresca and von Mises stresses. Go to Plot Parameters to find out what these predefined stresses are called (
mises_smsld if you are modeling in 3D with the Structural Mechanics Module). Now all you need to do is enter
sqrt(0.5*(tresca_smld^2+mises_smld^2)) in any of the Expression fields and click OK to see your new stress distribution.
You probably didn’t think of it, but in the expression I just mentioned,
^, and even
+ are all examples of operators. COMSOL offers a whole range of useful ones, not all equally obvious. Did you for instance know that the letter
d will differentiate any variable or expression with respect to time or space?
d(c,z) gives the derivative of a concentration
c with respect to the
d(sqrt(0.5*(tresca_smld^2+mises_smld^2)),t) is the time-derivative of your stress. If you have created your own subdomain expression
my_stress containing your stress definition,
d(my_stress,t) gives the same results.
at operator lets you access the solution at any time in postprocessing. This is handy if you want to see changes over a time interval. Plotting the expression
at(20,p)-at(10,p) overrides the Solution at time setting and shows you the pressure increase between 10 and 20 seconds. The
with operator lets you postprocess more than one parametric or eigensolution in a similar fashion.
Another handy pair of operators is
down. They live on boundaries and help you evaluate anything with discontinuities. Consider for example a temperature gradient on a boundary between two subdomains with different conductivities.
gradT_ht will silently evaluate this gradient on both sides of the boundary and give you the average. With
down(gradT_ht) however, you can decide which side you are interested in.
If you work with electromagnetics, you might have plotted the magnetic field in an eigenmode analysis only to find that it appears to be identically zero. Chances are it is non-zero but perfectly imaginary due to its 90-degree phase difference with a real-valued electric field. Use the
imag operator to show its imaginary part,
abs to plot the norm, or
arg to see the phase angle. Note that the default plot for complex fields shows the real part.
This is just the tip of the iceberg. You can find the complete list of mathematical and other operators in the COMSOL Multiphysics Quick Start and Quick Reference.
Article TagsCOMSOL Now
COMSOL First to Offer Free Cluster Support for Multiphysics Simulations with Windows HPC Server
- Certified Consultants 29
- Chemical 44
- COMSOL Now 130
- Conference 98
- Core Functionality 55
- Electrical 113
- Fluid 85
- Interfacing 34
- Mechanical 137
- Multipurpose 14
- Tips & Tricks 32
- Trending Topics 30
- User Perspectives 78
- Video 62