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.

A "Gloabl equation" problem

Please login with a confirmed email address before reporting spam

A PDE coupled with an ODE, the PDE is the heat transfer equation contain source term, like rho*Cp*dT/dt=k*d^2T/dx^2+S (one dimension). the ODE is dfc/dt=(Tm-T)*switch(t), where Tm is a constant, T is the temperature (independent variable of PDE), fc will be used when calculating "S" in heat transfer equation, switch(t) is a pre-defined function with respect to t.
To solve the ODE, I add a Global Equation under the Heat Transfer (ht) node, and the settings are as follows:
Name: fc
f(u, ut, utt, t): fct-(Tm-T)*switch(t)
Initial value (u_0): 0

When I try to solve the whole model, an error occurred:
Failed to evaluate variable Jacobian.
- Variable: mod1.T
- Global scope

Why?
the model file was attached.
Thank you!


14 Replies Last Post Jul 24, 2015, 4:42 a.m. EDT
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 May 24, 2011, 1:34 a.m. EDT
Hi

are you sure your "switch" is derivable ? normally you should use only smooth functions that might de derived at least once, ideally twice, you can use the Heavyside functions to smoothen "switches"

--
Good luck
Ivar
Hi are you sure your "switch" is derivable ? normally you should use only smooth functions that might de derived at least once, ideally twice, you can use the Heavyside functions to smoothen "switches" -- Good luck Ivar

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 24, 2011, 3:06 a.m. EDT
Hi,

The ODE is a scalar space-independent equation for a single scalar variable, so it is not possible to use T, which is the dependent variable for the temperature in the 1D domain and therefore a field quantity T = T(x,t). It has a local scope in the domain; hence the error message. Depending on the application (how is T defined for this ODE?), possible approaches could be to use:
* the value of T in a point
* the average temperature in the domain
* or replace the ODE with a "distributed ODE" (a PDE interface with no space derivatives; in 4.2 such a "Domain ODE and DAE" interface is predefined), where you solve an ODE in each point along the 1D domain.

Best regards,

Magnus Ringh, COMSOL
Hi, The ODE is a scalar space-independent equation for a single scalar variable, so it is not possible to use T, which is the dependent variable for the temperature in the 1D domain and therefore a field quantity T = T(x,t). It has a local scope in the domain; hence the error message. Depending on the application (how is T defined for this ODE?), possible approaches could be to use: * the value of T in a point * the average temperature in the domain * or replace the ODE with a "distributed ODE" (a PDE interface with no space derivatives; in 4.2 such a "Domain ODE and DAE" interface is predefined), where you solve an ODE in each point along the 1D domain. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 25, 2011, 3:43 p.m. EDT

Hi,

The ODE is a scalar space-independent equation for a single scalar variable, so it is not possible to use T, which is the dependent variable for the temperature in the 1D domain and therefore a field quantity T = T(x,t). It has a local scope in the domain; hence the error message. Depending on the application (how is T defined for this ODE?), possible approaches could be to use:
* the value of T in a point
* the average temperature in the domain
* or replace the ODE with a "distributed ODE" (a PDE interface with no space derivatives; in 4.2 such a "Domain ODE and DAE" interface is predefined), where you solve an ODE in each point along the 1D domain.

Best regards,

Magnus Ringh, COMSOL


Thank you, Magnus Ringh, it worked when I replaced the ODE with a "distributed ODE".
But now I encountered a another problem. For equation dfc/dt=(Tm-T)*switch(t), the model can work. When I used another ODE, i.e., dfc/dt=(Tm-T)*switch(t)* fc^(2/3), an error occurred:

Attempt to evaluate negative power of zero.
- Function: ^
Failed to evaluate expression.
- Expression: d(d((-(mod1.fct-(Tm-mod1.T)*switch(t/unit_s_cf)*mod1.fc^(2/3)/unit_K_cf)*test(mod1.fc))*(dvol),{test@2}),mod1.fc)

It was so strange! Why comsol regard (2/3) as a negative power?
[QUOTE] Hi, The ODE is a scalar space-independent equation for a single scalar variable, so it is not possible to use T, which is the dependent variable for the temperature in the 1D domain and therefore a field quantity T = T(x,t). It has a local scope in the domain; hence the error message. Depending on the application (how is T defined for this ODE?), possible approaches could be to use: * the value of T in a point * the average temperature in the domain * or replace the ODE with a "distributed ODE" (a PDE interface with no space derivatives; in 4.2 such a "Domain ODE and DAE" interface is predefined), where you solve an ODE in each point along the 1D domain. Best regards, Magnus Ringh, COMSOL [/QUOTE] Thank you, Magnus Ringh, it worked when I replaced the ODE with a "distributed ODE". But now I encountered a another problem. For equation dfc/dt=(Tm-T)*switch(t), the model can work. When I used another ODE, i.e., dfc/dt=(Tm-T)*switch(t)* fc^(2/3), an error occurred: Attempt to evaluate negative power of zero. - Function: ^ Failed to evaluate expression. - Expression: d(d((-(mod1.fct-(Tm-mod1.T)*switch(t/unit_s_cf)*mod1.fc^(2/3)/unit_K_cf)*test(mod1.fc))*(dvol),{test@2}),mod1.fc) It was so strange! Why comsol regard (2/3) as a negative power?

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 26, 2011, 3:56 a.m. EDT
Hi,

The expression is for computing the Jacobian (derivatvive) of the equation and takes the derivative of fc^(2/3) with respect to fc ("d" is the differentiation operator), which results in a negative power. If fc = 0, then fc^(-1/3), for example, is undefined.

You can perhaps change the initial value of fc to move it away from zero to avoid this problem.

Best regards,

Magnus Ringh, COMSOL
Hi, The expression is for computing the Jacobian (derivatvive) of the equation and takes the derivative of fc^(2/3) with respect to fc ("d" is the differentiation operator), which results in a negative power. If fc = 0, then fc^(-1/3), for example, is undefined. You can perhaps change the initial value of fc to move it away from zero to avoid this problem. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 2, 2011, 12:55 a.m. EDT
Hi guys, I am having the same problem. I was trying to see how can I use "distributed ODE" option. I am using COMSOL 4.1 and I can't find the way to use distributed ODE. Can anybody please explain?

Thank you
Hi guys, I am having the same problem. I was trying to see how can I use "distributed ODE" option. I am using COMSOL 4.1 and I can't find the way to use distributed ODE. Can anybody please explain? Thank you

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 2, 2011, 9:42 a.m. EDT

Hi guys, I am having the same problem. I was trying to see how can I use "distributed ODE" option. I am using COMSOL 4.1 and I can't find the way to use distributed ODE. Can anybody please explain?

Thank you


You can use the PDE interface, since there is no distributed ODE in 4.1.
[QUOTE] Hi guys, I am having the same problem. I was trying to see how can I use "distributed ODE" option. I am using COMSOL 4.1 and I can't find the way to use distributed ODE. Can anybody please explain? Thank you [/QUOTE] You can use the PDE interface, since there is no distributed ODE in 4.1.

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 2, 2011, 10:04 a.m. EDT
Distributed ODEs and DAEs are available in version 4.2. It's one of the new features listed here: www.comsol.com/products/4.2/
Distributed ODEs and DAEs are available in version 4.2. It's one of the new features listed here: http://www.comsol.com/products/4.2/

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 23, 2011, 6:04 a.m. EST
Hi,
I am attempting something similar. Instead of an ODE, I have a transcendental function of the form

MS=M0*tanh(MS*TC/(M0*T))

in the ODE physics. M0 and TC are constants while T is the dependent variable (temperature) in the heat transfer physics. MS is to be used in the heat source term in the heat transfer physics.

I obtained basically the same error, viz Failed to evaluate variable Jacobian: Variable: mod1.T; Global scope.


Since my global function is a transcendental function and not an ODE, I assume that the Distributed ODE is no longer applicable.

Can anyone help me with this issue?

Thank you.


Sincerely,
EH
Hi, I am attempting something similar. Instead of an ODE, I have a transcendental function of the form MS=M0*tanh(MS*TC/(M0*T)) in the ODE physics. M0 and TC are constants while T is the dependent variable (temperature) in the heat transfer physics. MS is to be used in the heat source term in the heat transfer physics. I obtained basically the same error, viz Failed to evaluate variable Jacobian: Variable: mod1.T; Global scope. Since my global function is a transcendental function and not an ODE, I assume that the Distributed ODE is no longer applicable. Can anyone help me with this issue? Thank you. Sincerely, EH

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 Nov 23, 2011, 6:40 a.m. EST
Hi

could it be that your eqation as a little issue around T=0, at least to derive a valuable derivative of the function.

I agree normally T > 0 but sometimes with the initial conditions by default at all = 0 one get fooled

It's just a suggestion, not sure its the true issue

--
Good luck
Ivar
Hi could it be that your eqation as a little issue around T=0, at least to derive a valuable derivative of the function. I agree normally T > 0 but sometimes with the initial conditions by default at all = 0 one get fooled It's just a suggestion, not sure its the true issue -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 23, 2011, 6:55 a.m. EST
Hi,
Thanks for the quick reply. Well, I have specified the initial values for T to be 310K. The idea here is to solve the transcendental function first to get MS using the initial T. Then with the calculated MS, the heat transfer is solved. Using the value of T, the transcendental fucntion is again solved for the next time step and this is repeated.

It seems that I couldnt get the first run to solve. By the way, are the initial values of (u_0) and (u_t0) important or can they just be zero? Do the initial values refer to the values at time zero or are they the initial values used for solving the transcendental functions via iterative methods?

Thank you.


Best regards,
EH
Hi, Thanks for the quick reply. Well, I have specified the initial values for T to be 310K. The idea here is to solve the transcendental function first to get MS using the initial T. Then with the calculated MS, the heat transfer is solved. Using the value of T, the transcendental fucntion is again solved for the next time step and this is repeated. It seems that I couldnt get the first run to solve. By the way, are the initial values of (u_0) and (u_t0) important or can they just be zero? Do the initial values refer to the values at time zero or are they the initial values used for solving the transcendental functions via iterative methods? Thank you. Best regards, EH

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 Nov 23, 2011, 7:29 a.m. EST
Hi

the u_0 and u_t0 are the initial values the programme is using for the Global Equation, SO THEY ARE IMPORTANT !

Try setting your u_0 to 310, the same for u_t0 (even if this one is only used if the time dependent solver is active)

--
Good luck
Ivar
Hi the u_0 and u_t0 are the initial values the programme is using for the Global Equation, SO THEY ARE IMPORTANT ! Try setting your u_0 to 310, the same for u_t0 (even if this one is only used if the time dependent solver is active) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 10 years ago Feb 13, 2015, 5:47 a.m. EST
Cav you give me your email id so that I can talk to you in this regard in more details.
Cav you give me your email id so that I can talk to you in this regard in more details.

Walter Frei COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 10 years ago Mar 4, 2015, 9:35 a.m. EST
Hello All,

This is a rather wide-ranging discussion, and I see that the original question was about switching a heat load on and off at known times during the simulation. For this type of pulsed heat loading, you will find the following blog helpful:
www.comsol.com/blogs/modeling-a-periodic-heat-load/

Best Regards,
Hello All, This is a rather wide-ranging discussion, and I see that the original question was about switching a heat load on and off at known times during the simulation. For this type of pulsed heat loading, you will find the following blog helpful: http://www.comsol.com/blogs/modeling-a-periodic-heat-load/ Best Regards,

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jul 24, 2015, 4:42 a.m. EDT
Hi Magnus,

I saw this thread while I was looking for help for almost similar two equations. I used Coefficient form PDE for the heat equation and Distributed ODE to solve fc. The fc here is defined as dimensionless variable.

My question is how to set up a time dependent study in which simulation stops when fc reaches 1 at every point in the domain, rather then specifying time range for the transient Analysis.
Thank you
Hi Magnus, I saw this thread while I was looking for help for almost similar two equations. I used Coefficient form PDE for the heat equation and Distributed ODE to solve fc. The fc here is defined as dimensionless variable. My question is how to set up a time dependent study in which simulation stops when fc reaches 1 at every point in the domain, rather then specifying time range for the transient Analysis. Thank you

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.