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.

Step function

Please login with a confirmed email address before reporting spam

Very simple question, but I can't find out how to do it.

I have a external temperature, "Temperature 1", which is 100 C. After 330 seconds I would like it to drop 80 degrees to 20 degrees. I should be able to use a step funtion, but can't figure out how to. An easier approach is also very welcome. Thanks in advance!

18 Replies Last Post 19.08.2015, 12:41 GMT-4
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 13.12.2011, 05:33 GMT-5
Hi

I would try to define a function

an1(x) as 100-(100-20)*step1(x)

with step1() defined as: location: 330, from: 0 to: 1

then plot an1() from 0-400 to check

calling with

an1(t[1/s])

--
Good luck
Ivar
Hi I would try to define a function an1(x) as 100-(100-20)*step1(x) with step1() defined as: location: 330, from: 0 to: 1 then plot an1() from 0-400 to check calling with an1(t[1/s]) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 06.11.2012, 10:41 GMT-5
Hi Ivar,

just in resonse to this link. I have a similar problem. I have two magnets, one which i want to start at a certain magnetization M and the other to start at 0. I want to then decrease the first magnet from M to 0 over time and increase the magnetization of the other magnet from 0 to M at the same time. Would you suggest using a step function or a ramp function? And should i have one for each? Thanks for you help.

Phil
Hi Ivar, just in resonse to this link. I have a similar problem. I have two magnets, one which i want to start at a certain magnetization M and the other to start at 0. I want to then decrease the first magnet from M to 0 over time and increase the magnetization of the other magnet from 0 to M at the same time. Would you suggest using a step function or a ramp function? And should i have one for each? Thanks for you help. Phil

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 06.11.2012, 17:33 GMT-5
Hi

That sounds like a ramp function, no ?
from 0-1 and then 1-ramp(t[1/s]) from 1 to 0

--
Good luck
Ivar
Hi That sounds like a ramp function, no ? from 0-1 and then 1-ramp(t[1/s]) from 1 to 0 -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 08.11.2012, 05:59 GMT-5
Hi,

Thanks for your quick response. Do you have to specify a time range to evaluate that over or use a parametric sweep? Or does that automatically link in with the time you run the model for? Apologies for the inconvenience.

Cheers,

Phil
Hi, Thanks for your quick response. Do you have to specify a time range to evaluate that over or use a parametric sweep? Or does that automatically link in with the time you run the model for? Apologies for the inconvenience. Cheers, Phil

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 08.11.2012, 06:25 GMT-5
Hi
you need to be "slow" to be in the ACDC regime but then the solver will adapt the time steps to the slope (if it will not ignore them by skipping over them), some time stepping values to give a good sampling of the slopes would be required, and a strict or intermediate (and not free-automatic) time stepping

--
Good luck
Ivar
Hi you need to be "slow" to be in the ACDC regime but then the solver will adapt the time steps to the slope (if it will not ignore them by skipping over them), some time stepping values to give a good sampling of the slopes would be required, and a strict or intermediate (and not free-automatic) time stepping -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 02.12.2012, 15:19 GMT-5
Is there a good place to learn about how to use the step function and ramp function? I have worked the "flow past a cylinder" example and I am asked to input "U_mean*6*s*(s-1)*step1(t[1/s])" as the inlet velocity, but I don't know what that means. I read the help and it does not define "s" very well (I am left with the question "how do I set a value for "s" and what is the domain) and I do not understand what "t[1/s]" means.
Is there a good place to learn about how to use the step function and ramp function? I have worked the "flow past a cylinder" example and I am asked to input "U_mean*6*s*(s-1)*step1(t[1/s])" as the inlet velocity, but I don't know what that means. I read the help and it does not define "s" very well (I am left with the question "how do I set a value for "s" and what is the domain) and I do not understand what "t[1/s]" means.

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 03.12.2012, 05:13 GMT-5
Hi,

See the COMSOL Multiphysics User's Guide and Reference Guide, or search the COMSOL Documentation to also find model examples where step functions and ramp functions are used.

In this particular model's documentation, an explanation of the expression "U_mean*6*s*(s-1)*step1(t[1/s])" is missing. The expression defines a parabolic velocity profile at the inlet boundary using the curve parameter "s", which is a predefined curve parameter on boundaries in 2D models and runs from 0 to 1 along the direction of the boundary. The smoothed step function ramps up the velocity at the start of the simulation. The step function's input "t[1/s]" is the predefined variable "t" for the time (unit: s) and the "unit multiplication" using "[1/s]" is done to make the step function's input dimensionless.

Best regards,
Magnus Ringh, COMSOL
Hi, See the COMSOL Multiphysics User's Guide and Reference Guide, or search the COMSOL Documentation to also find model examples where step functions and ramp functions are used. In this particular model's documentation, an explanation of the expression "U_mean*6*s*(s-1)*step1(t[1/s])" is missing. The expression defines a parabolic velocity profile at the inlet boundary using the curve parameter "s", which is a predefined curve parameter on boundaries in 2D models and runs from 0 to 1 along the direction of the boundary. The smoothed step function ramps up the velocity at the start of the simulation. The step function's input "t[1/s]" is the predefined variable "t" for the time (unit: s) and the "unit multiplication" using "[1/s]" is done to make the step function's input dimensionless. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28.12.2012, 02:53 GMT-5
Hi,

I am trying to specify the material property as a function of y. My geometry is a rectangle divided in the middle into two domains. I would like to define the young's modulus as a single variable that changes from E1 in domain 1 to E2 in domain 2 smoothly. Is that possible with step function?

Thanks.

Lakshmi.
Hi, I am trying to specify the material property as a function of y. My geometry is a rectangle divided in the middle into two domains. I would like to define the young's modulus as a single variable that changes from E1 in domain 1 to E2 in domain 2 smoothly. Is that possible with step function? Thanks. Lakshmi.

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28.12.2012, 04:58 GMT-5
Hi

you can define your material properties with the user defined option to any function related to x,y,z ... at will, it must "just" be more or less derivable (smooth) to allow COMSOL to extract the Jacobian for the solving process

You can define your Young modulus for both domain as the same function E0+E1*step1(y-Y0) at will ;)

--
Good luck
Ivar
Hi you can define your material properties with the user defined option to any function related to x,y,z ... at will, it must "just" be more or less derivable (smooth) to allow COMSOL to extract the Jacobian for the solving process You can define your Young modulus for both domain as the same function E0+E1*step1(y-Y0) at will ;) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28.12.2012, 08:50 GMT-5
Thanks Ivar. That helped.

Best regards
Lakshmi
Thanks Ivar. That helped. Best regards Lakshmi

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 17.03.2013, 11:52 GMT-4
Hi Ivar,
I am working on a thermomagnetic convection problem using AC-DC and non-isothermal flow modules. I have a heat source in the magnetic fluid field. I want to use a function for magnetization of my magnetic fluid up to the temperature of fluid is less than a defined quantity as Tc, and after this temperature I want to use zero for the magnetization function, I was wondering if you could let me know how I can use step function here?
Thank you so much in advance,
Giti
Hi Ivar, I am working on a thermomagnetic convection problem using AC-DC and non-isothermal flow modules. I have a heat source in the magnetic fluid field. I want to use a function for magnetization of my magnetic fluid up to the temperature of fluid is less than a defined quantity as Tc, and after this temperature I want to use zero for the magnetization function, I was wondering if you could let me know how I can use step function here? Thank you so much in advance, Giti

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 17.03.2013, 14:38 GMT-4
Hi

there are probably several ways, but I would suggest to change your material data accordingly so that it is sensitive to B below Tc and not above, that is make some analyitical or interpolation function of what ever magnetic property of the material that in giving a heat source.

You could take a look at the examples of the BH curve for soft iron with saturation, that is B dependent, you do something similat for T dependence.

Then whe you solve, think about the order of the segregated steps if you cannot use a direct solver

--
Good luck
Ivar
Hi there are probably several ways, but I would suggest to change your material data accordingly so that it is sensitive to B below Tc and not above, that is make some analyitical or interpolation function of what ever magnetic property of the material that in giving a heat source. You could take a look at the examples of the BH curve for soft iron with saturation, that is B dependent, you do something similat for T dependence. Then whe you solve, think about the order of the segregated steps if you cannot use a direct solver -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.03.2013, 10:48 GMT-4
Thank you so much Ivar, it was so helpful.
Thank you so much Ivar, it was so helpful.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28.04.2013, 13:07 GMT-4
Hi everyone and Ivar,

I was hoping somebody here could help me with my problem related to the step function as well.

In my model I have as a boundary condition a partial pressure dependent current function such as j = pH2O^0.5*exp(...) for example. When I vary the current to higher values (stationary simulation), more of the gas spezies is consument at the boundary by a current dependent reactions term and will eventually reach zero at the boundary due to diffusion limitations.

At that point, the simulation stopps because of non converging solution, which should be related to numerical problems with the low partial pressure, right? I found in the COMSOL user guide the step function as a possible aid for converging problems due to over or undershots of the solution...

However, I have no idea how to make use of the smoothing capabilities since I don't know in what way to apply the step function to my model equations. I tried a boolian expression like pH2O=if(chcs.x_wH2O>0.001, chcs.x_wH2O,0.001), but wihout any success. Should I declare a variable with relation to the partial pressure where the step function is involved somehow? How do I make use of the step function since I have a stationary simulation, where the last solution is the intial value for the next stationary simulation?

I would really appriciate any help related to this problem, I been stuck now for some time!!!

Thanks a lot in advance!
Cheers Helge
Hi everyone and Ivar, I was hoping somebody here could help me with my problem related to the step function as well. In my model I have as a boundary condition a partial pressure dependent current function such as j = pH2O^0.5*exp(...) for example. When I vary the current to higher values (stationary simulation), more of the gas spezies is consument at the boundary by a current dependent reactions term and will eventually reach zero at the boundary due to diffusion limitations. At that point, the simulation stopps because of non converging solution, which should be related to numerical problems with the low partial pressure, right? I found in the COMSOL user guide the step function as a possible aid for converging problems due to over or undershots of the solution... However, I have no idea how to make use of the smoothing capabilities since I don't know in what way to apply the step function to my model equations. I tried a boolian expression like pH2O=if(chcs.x_wH2O>0.001, chcs.x_wH2O,0.001), but wihout any success. Should I declare a variable with relation to the partial pressure where the step function is involved somehow? How do I make use of the step function since I have a stationary simulation, where the last solution is the intial value for the next stationary simulation? I would really appriciate any help related to this problem, I been stuck now for some time!!! Thanks a lot in advance! Cheers Helge

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 29.04.2013, 02:33 GMT-4
Hi

if its an issue with the pH2O = "0" or getting into negastive values, sometimes it can be solve by adding a small value, such as "eps" sqrt(eps) or a multiple thereof to your equation.

The boolean equations adds discontinuitites that often make the solver fail

I have noticved one are often having trouble with negative values in electrochemistry, but there must be other with greater experience than me that have some tricks to propose

--
Good luck
Ivar
Hi if its an issue with the pH2O = "0" or getting into negastive values, sometimes it can be solve by adding a small value, such as "eps" sqrt(eps) or a multiple thereof to your equation. The boolean equations adds discontinuitites that often make the solver fail I have noticved one are often having trouble with negative values in electrochemistry, but there must be other with greater experience than me that have some tricks to propose -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.08.2013, 11:26 GMT-4
Hello everyone,
I am trying to model laser photothermal therapy on cancer tumors. In the bioheat model, the
omega is the blood perfusion of tumor which varies depending on temperature range .
For T<37 omega= 0.833
For 37<T<42 omega=0.833-((T-37)^4.8)/5.438e3
For T>42 omega= 0.416

I defined two step functions under global definitions (step1) Location:37 from 0.833 to 0.833-((T-37)^4.8)/5.438e3
(step2) Location:42 From:0.833-((T-37)^4.8)/5.438e3 to:0.416

Bioheat :
step1*step2*rou*Cp*(Ta-T)+Qt...

Do you think this is a right approach?


Thanks
Hello everyone, I am trying to model laser photothermal therapy on cancer tumors. In the bioheat model, the omega is the blood perfusion of tumor which varies depending on temperature range . For T

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 27.03.2014, 08:53 GMT-4
Hi all,

I want to define step function for my boundary like this:
For y<0.78 , Hp=0.5
For y>=0.78, Hp=0

How should I write it with flc2hs function?

Thanks in advance for your help,
Sepideh
Hi all, I want to define step function for my boundary like this: For y=0.78, Hp=0 How should I write it with flc2hs function? Thanks in advance for your help, Sepideh

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 19.08.2015, 12:41 GMT-4

Hi,

See the COMSOL Multiphysics User's Guide and Reference Guide, or search the COMSOL Documentation to also find model examples where step functions and ramp functions are used.

In this particular model's documentation, an explanation of the expression "U_mean*6*s*(s-1)*step1(t[1/s])" is missing. The expression defines a parabolic velocity profile at the inlet boundary using the curve parameter "s", which is a predefined curve parameter on boundaries in 2D models and runs from 0 to 1 along the direction of the boundary. The smoothed step function ramps up the velocity at the start of the simulation. The step function's input "t[1/s]" is the predefined variable "t" for the time (unit: s) and the "unit multiplication" using "[1/s]" is done to make the step function's input dimensionless.

Best regards,
Magnus Ringh, COMSOL


Hi,
what is a parabolic velocity profile in 3D models?
Regards
Ahmed Atrah
[QUOTE] Hi, See the COMSOL Multiphysics User's Guide and Reference Guide, or search the COMSOL Documentation to also find model examples where step functions and ramp functions are used. In this particular model's documentation, an explanation of the expression "U_mean*6*s*(s-1)*step1(t[1/s])" is missing. The expression defines a parabolic velocity profile at the inlet boundary using the curve parameter "s", which is a predefined curve parameter on boundaries in 2D models and runs from 0 to 1 along the direction of the boundary. The smoothed step function ramps up the velocity at the start of the simulation. The step function's input "t[1/s]" is the predefined variable "t" for the time (unit: s) and the "unit multiplication" using "[1/s]" is done to make the step function's input dimensionless. Best regards, Magnus Ringh, COMSOL [/QUOTE] Hi, what is a parabolic velocity profile in 3D models? Regards Ahmed Atrah

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.