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 solve ODE in comsol 4.0a

Please login with a confirmed email address before reporting spam

Dear all ,

I want to solve coupled following ODE for specific geometry , is comsol capable of solving this ?

dT/dt=(Qg-H-T*C*M)
dh/dt=-G*B*(Ys)

G,F,C=const
H=M*(C*T+F)
T=Temperature
Ys=Temperature dependant
B & Qg = Temperature and Height dependant
h=Height

Is there any stepwise toturial exists in this regard? I tried global equation in ODE but I do not know how could I define coupling and temperature and height dependant variables ?

11 Replies Last Post 05.07.2014, 10:23 GMT-4
Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.03.2011, 05:07 GMT-4
Hi,

You can define and solve systems of coupled global equations such as ODEs. Use the Settings window for the Global Equations node to define the equations using the left side of a general equation f(u,ut,utt,t) = 0, where u is a dependent variable, and the suffix "t" indicates the time derivative. In your case, define two equations on two rows:

Row 1: Name: T; f(u,ut,utt,t): Tt-Qg+H+T*C*M
Row 2: Name: h; f(u,ut,utt,t): ht+G*B*Ys

using COMSOL's syntax where Tt = dT/dt etc.

Define G, F, and C as Global Parameters, and define H, Ys, B, and Qg as local Variables, which can be functions of T and h and the parameters.

You also need to defined initial values for T and h.

Solve the system of ODEs using a Time Dependent study, where you define the range for the time stepping.

To plot the solution, use a 1D Plot Group with a Global plot, where the "state variables" T and h are available as predefined quantities.

Best regards,
Magnus Ringh, COMSOL
Hi, You can define and solve systems of coupled global equations such as ODEs. Use the Settings window for the Global Equations node to define the equations using the left side of a general equation f(u,ut,utt,t) = 0, where u is a dependent variable, and the suffix "t" indicates the time derivative. In your case, define two equations on two rows: Row 1: Name: T; f(u,ut,utt,t): Tt-Qg+H+T*C*M Row 2: Name: h; f(u,ut,utt,t): ht+G*B*Ys using COMSOL's syntax where Tt = dT/dt etc. Define G, F, and C as Global Parameters, and define H, Ys, B, and Qg as local Variables, which can be functions of T and h and the parameters. You also need to defined initial values for T and h. Solve the system of ODEs using a Time Dependent study, where you define the range for the time stepping. To plot the solution, use a 1D Plot Group with a Global plot, where the "state variables" T and h are available as predefined quantities. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.03.2011, 10:10 GMT-4

Dear Magnus Ringh,

Thank you very much for your reply , I went through the steps you mentioned but I got error 'compile equation' , via attachment I sent you comsol file and brief discription of equations , would you please guide me about following points ,

how could I debug and solve this coupled equations ?

Do I need to build geometry and mesh for solving these equations?

Could I , instead of defining Ad , refer to specific geometry and it decrease with time ?


thank you in advance

kind regards

Maryam
Dear Magnus Ringh, Thank you very much for your reply , I went through the steps you mentioned but I got error 'compile equation' , via attachment I sent you comsol file and brief discription of equations , would you please guide me about following points , how could I debug and solve this coupled equations ? Do I need to build geometry and mesh for solving these equations? Could I , instead of defining Ad , refer to specific geometry and it decrease with time ? thank you in advance kind regards Maryam


Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.03.2011, 11:27 GMT-4
Hi,

I haven't checked if what you've entered matches the equations in the document, but I can make the model run by fixing these two issues:

- In the equation for h, two closing right parentheses are missing.
- The user-defined variables include h and T and must be defined as "local" variable in the model. Add them to Model 1>Definitions>Variables instead of Global Definitions>Variables. You can save the defined variables to a text file and then import them into the new Variables node. That way you do not need to type in the variable definitions again.

Also, replace the 2D Plot Group with a 1D Plot Group including a Global plot to see the values of T and h vs. time.

Best regards,
Magnus Ringh, COMSOL
Hi, I haven't checked if what you've entered matches the equations in the document, but I can make the model run by fixing these two issues: - In the equation for h, two closing right parentheses are missing. - The user-defined variables include h and T and must be defined as "local" variable in the model. Add them to Model 1>Definitions>Variables instead of Global Definitions>Variables. You can save the defined variables to a text file and then import them into the new Variables node. That way you do not need to type in the variable definitions again. Also, replace the 2D Plot Group with a 1D Plot Group including a Global plot to see the values of T and h vs. time. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 22.03.2011, 09:22 GMT-4
Dear Mr.Magnus Ringh,

I really thank you for your previous useful suggestions. My model ran

I have another question regarding implementing this coupling solution on specific geometry.
In 4a-7 file in the attachment. I tried to use moving mesh ALE and with solving h, simultaneously height of geometry reduces in Z direction. Is it possible to link these two methods? Would you guide me in this regards?
What is possible way to solve PDE or ODE for specific Geometry in comsol ?

kind regards

Maryam
Dear Mr.Magnus Ringh, I really thank you for your previous useful suggestions. My model ran I have another question regarding implementing this coupling solution on specific geometry. In 4a-7 file in the attachment. I tried to use moving mesh ALE and with solving h, simultaneously height of geometry reduces in Z direction. Is it possible to link these two methods? Would you guide me in this regards? What is possible way to solve PDE or ODE for specific Geometry in comsol ? kind regards Maryam


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 27.03.2011, 20:27 GMT-4
Hi,

I am trying to couple a system of 3 ODE's with a transient heat transfer study (conduction with a heat source and convective cooling BC)in a VERY simple geometry. I am using the SHNEIDER equations for crystallization.

The relative degree of crystallization "alpha" (0<alpha<1), defined in local variables, is a function of a quantity "phi0(t)" that verifies the Shneider system such as:

name: "phi0" f(u,ut,utt,t): phi0t - G*phi1
name: "phi1" f(u,ut,utt,t): phi1t - G*phi2
name: "phi2" f(u,ut,utt,t): phi2t - G*N

(initial values for "alpha", "phi0", "phi1" and "phi2" = 0)

Where G and N are local temperature-dependent variables defined by simple Boolean expressions under "Model1" [please check the attached picture to see their expressions].

To be more specific, I want COMSOL to compute at each time step the solution of this system giving the value of "alpha" on which depend the material overall properties, starting from alpha(initial condition)=0. This way, I could follow the crystallization process during the cooling phase.

Although it's simple, I can't really understand what goes wrong:
"Failed to evaluate Variable mod1.T - Global Scope" ...... Is it the "alpha" that should be defined differently ?
Any help, clue or idea would be greatly appreciated.


Regards,
Ali
Hi, I am trying to couple a system of 3 ODE's with a transient heat transfer study (conduction with a heat source and convective cooling BC)in a VERY simple geometry. I am using the SHNEIDER equations for crystallization. The relative degree of crystallization "alpha" (0


Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28.03.2011, 03:34 GMT-4
Hi,

I think that the problem is that you use the variable T for the temperature field in the definition of variables used in the ODEs. It is not possible to use spatially distributed variables in ODEs that are global equations, so a temperature value in that context must be a scalar value. For a "distributed ODE" (solved in a domain, for example) you can use one of the PDE interfaces with all spatial derivatives set to 0.

To remove the unit warning (orange) in the Variables definitions, you need to "de-dimensionalize" the expression in the exponential for the variable alpha (using C0[s], for example).

Best regards,
Magnus Ringh, COMSOL
Hi, I think that the problem is that you use the variable T for the temperature field in the definition of variables used in the ODEs. It is not possible to use spatially distributed variables in ODEs that are global equations, so a temperature value in that context must be a scalar value. For a "distributed ODE" (solved in a domain, for example) you can use one of the PDE interfaces with all spatial derivatives set to 0. To remove the unit warning (orange) in the Variables definitions, you need to "de-dimensionalize" the expression in the exponential for the variable alpha (using C0[s], for example). Best regards, Magnus Ringh, COMSOL

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.03.2011, 00:28 GMT-4
Hi Magnus

I believe that the KB could gain by an article describing the implicit notation of COMSOL(ux=du/dx, u(x,y,z,t) ...), including the subtile differences of global variables, Parameters (loaded once ?), model variables, dependent variables ...

And most important with some simple examples linking the mathematics to these expressions

Then a reminder on the frames (or a reference as I believe to remeber there is a KB on frames, or was it in the help ?, only missing: is some real simple examples to really illustrate the effects)

And finally a reminder of the convention for coordinates systems, once one is defined, you can refer to them, but also to the transform matrix T11...

--
Good luck
Ivar
Hi Magnus I believe that the KB could gain by an article describing the implicit notation of COMSOL(ux=du/dx, u(x,y,z,t) ...), including the subtile differences of global variables, Parameters (loaded once ?), model variables, dependent variables ... And most important with some simple examples linking the mathematics to these expressions Then a reminder on the frames (or a reference as I believe to remeber there is a KB on frames, or was it in the help ?, only missing: is some real simple examples to really illustrate the effects) And finally a reminder of the convention for coordinates systems, once one is defined, you can refer to them, but also to the transform matrix T11... -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.09.2011, 13:26 GMT-4
i have an error of singularity pls see into it
i have an error of singularity pls see into it


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19.04.2012, 13:42 GMT-4
Hi Ivar,
I need help! I am trying to apply an Arrhenius damage integral DURING the solution of an thermal ablation problem using the heat Transfer, electric currents and PDE coefficient form Modules (T, V and u are the dependent variables).
The integral is of the form:

Arrh = integral(A*exp(-E/(R*T))dt)

where Arrh is the Arrenhius damage integral, t is time and A, E, and R are constants. T is the nodal tissue temperature and t is time. I am trying to solve it using the PDE coefficient form Module. However, in the end of the simulation, it appears the following message:
"Error:
Failed to find consistent initial values.
Out_of_memory_LU_factorization
Last time step is not converged."
Any help is WELCOME!
Best regards,
Cleber
Hi Ivar, I need help! I am trying to apply an Arrhenius damage integral DURING the solution of an thermal ablation problem using the heat Transfer, electric currents and PDE coefficient form Modules (T, V and u are the dependent variables). The integral is of the form: Arrh = integral(A*exp(-E/(R*T))dt) where Arrh is the Arrenhius damage integral, t is time and A, E, and R are constants. T is the nodal tissue temperature and t is time. I am trying to solve it using the PDE coefficient form Module. However, in the end of the simulation, it appears the following message: "Error: Failed to find consistent initial values. Out_of_memory_LU_factorization Last time step is not converged." Any help is WELCOME! Best regards, Cleber


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19.04.2012, 15:32 GMT-4
I have set up my problem which is a system of 3 ODE's using the Global ODEs and DAEs

f(T,Tt,V,H)=0: Tt-5/(5+V)+mu*T-r*T*V/(C+V)+z*kv*T*V=0
f(H,Ht,V,H)=0: Ht-z*kv*T*V+muT*H+r*H*V/(C+V)=0
f(V,Vt,V,H)=0: Vt-n*r*H*V/(C+V)+kT*T*V-gv*V/(c+V)=0

The graphs I am getting are Tt vrs time, Ht vrs time and Vt vrs time. How do I get plotss for T vrs time, H vrs time and V vrs time.

I have attached my COMSOL 4.2 program
I have set up my problem which is a system of 3 ODE's using the Global ODEs and DAEs f(T,Tt,V,H)=0: Tt-5/(5+V)+mu*T-r*T*V/(C+V)+z*kv*T*V=0 f(H,Ht,V,H)=0: Ht-z*kv*T*V+muT*H+r*H*V/(C+V)=0 f(V,Vt,V,H)=0: Vt-n*r*H*V/(C+V)+kT*T*V-gv*V/(c+V)=0 The graphs I am getting are Tt vrs time, Ht vrs time and Vt vrs time. How do I get plotss for T vrs time, H vrs time and V vrs time. I have attached my COMSOL 4.2 program


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 05.07.2014, 10:23 GMT-4
Hi Ali Saad,

Have you solved your problem ?
I am trying different but similar type of approach. Could you advise me.

Thanks,
SN
Hi Ali Saad, Have you solved your problem ? I am trying different but similar type of approach. Could you advise me. Thanks, SN

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.