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.

ASK: easy functions in COMSOL4.3

Please login with a confirmed email address before reporting spam

Hi there,

I am now trying to model a moving laser beam (as heat flux) on a steel plate. I try to do this by following steps:
1. build a solid block (domain 1) to represent the steel plate.
2. set 'heat flux' on one of the surfaces (boundary 1).
3. type in all the parameters including r0(laser on-plate beam diameter), Q(laser power)
4. to implement a moving laser beam, I use variables x0, y0(laser center coordinates, time dependent, x0=0+2*t, y0=1+2*t, speed=2).
Now I encounter problems to specify the heat flux on the boundary. What I want to do is to set it this way:
****************
function [q_in] = SetHeatFlux(x, x0, y, y0, r0, Q)

distance=(sqrt(x-x0)^2+(y-y0)^2);
if distance<=r0
q_in=Q/(pi*r0^2);
else
q_in=0;
end
****************
Well, first let us forget about the moving laser, i.e. x0, y0 = constant. The aforementioned function may be implemented using LiveLink for MATLAB, but the manual says that I have to make all the input and output vectors, which brings too much trouble as I am not good at handling matrix··· I would prefer an easy function like this.

Could you help me? My appreciations.

Ce ZHU




3 Replies Last Post 30 sept. 2013, 04:56 UTC−4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 26 sept. 2013, 02:47 UTC−4
Hi,

For distance and q_in you can define following variables:

distance (sqrt(x-x0)^2+(y-y0)^2
q_in if(distance<=r0,Q/(pi*r0^2),0)

r0 needs to defined too.

Place these under "variables".

Best regards

Tero
Hi, For distance and q_in you can define following variables: distance (sqrt(x-x0)^2+(y-y0)^2 q_in if(distance

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 26 sept. 2013, 05:54 UTC−4
Hi Tero,
Thanks for your help. It works well. However, I am now having other problems. Instead of simple scan path like a straight line or a circle, I need to study complex paths like spiral, zigzag, and so on. You may consider that I need to use a lot of functions likes if(), for(). If I use the built-in functions of COMSOL, there will be too many variables. A user defined function like a m-file of MATLAB will be great (no such file or script in COMSOL, right?). The problem of LiveLink of MATLAB may be that I need to cope with vectors. Input arguments like power, radius of the laser beam, scanning velocity which are constant parameters may be not easy to handle as vectors in equations. I would much prefer to use them as scalar. What kind of program strategy would you recommend? Is there any modelling skills and concepts I need to know?
BTW, using external functions will definitely slow down the calculation right? But to what extent? What kind of external functions you would recommend, Matlab, C ?

Warm regards,
Ce
Hi Tero, Thanks for your help. It works well. However, I am now having other problems. Instead of simple scan path like a straight line or a circle, I need to study complex paths like spiral, zigzag, and so on. You may consider that I need to use a lot of functions likes if(), for(). If I use the built-in functions of COMSOL, there will be too many variables. A user defined function like a m-file of MATLAB will be great (no such file or script in COMSOL, right?). The problem of LiveLink of MATLAB may be that I need to cope with vectors. Input arguments like power, radius of the laser beam, scanning velocity which are constant parameters may be not easy to handle as vectors in equations. I would much prefer to use them as scalar. What kind of program strategy would you recommend? Is there any modelling skills and concepts I need to know? BTW, using external functions will definitely slow down the calculation right? But to what extent? What kind of external functions you would recommend, Matlab, C ? Warm regards, Ce

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30 sept. 2013, 04:56 UTC−4
Hi,

Sorry for late reply...

Difficult task! I don't have experience external programs with Comsol so I cannot help you with this. Sorry.

Best regards

Tero
Hi, Sorry for late reply... Difficult task! I don't have experience external programs with Comsol so I cannot help you with this. Sorry. Best regards Tero

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.