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.

Implicit Equation Solution

Rajlakshmi Purkayastha

Please login with a confirmed email address before reporting spam

Hi,

I am trying to solve Butler Volmer equations for my boundary conditions and my equations have a circular dependency.

eta = V - U - i*R

i = i0*exp(eta*k)

COMSOL will detect an error. How do i set just an initial value to get the system going? I would like to set eta to U(t=0) and then start the equations.

Would it be possible to simply use a value from a previous time step for one equation (which would then solve the other in the current time step) ? Not accurate but atleast a solution!

Thanks!
Best Regards
raj

14 Replies Last Post 24 avr. 2012, 10:44 UTC−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 10 juil. 2010, 15:23 UTC−4
Hi

you would need V4 to easily use a "previous" step value (new feature), but that's something I havent tried yet, so I cannot help

Good luck
Ivar
Hi you would need V4 to easily use a "previous" step value (new feature), but that's something I havent tried yet, so I cannot help Good luck Ivar

Rajlakshmi Purkayastha

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 10 juil. 2010, 15:28 UTC−4
Thanks Ivar! I'll try and get my hands on COMSOL 4.0 .

I know that Matlab has an implicit solver (simply using fsolve). I was able to create a look up table of sorts but it isnt entirely accurate. Would it be possible to link fsolve with my equation in COMSOL ?

Thanks!
Best Regards
raj
Thanks Ivar! I'll try and get my hands on COMSOL 4.0 . I know that Matlab has an implicit solver (simply using fsolve). I was able to create a look up table of sorts but it isnt entirely accurate. Would it be possible to link fsolve with my equation in COMSOL ? Thanks! Best Regards raj

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 janv. 2011, 08:05 UTC−5
Has anyone found a solution to this problem? I struggle with the same problem and I think it is quite fundamental to be able to solve such systems of equations. I suppose it should be possible, since even with a simple algorithm for 1D cases you should be able to do it "by hand" in a spreadsheat program.
The comment Ivar gave, to use the time discrete solver and use the "prev" command has not worked for me sofar. I suppose it still has to do with initialization of the problem, since I still get circular variable dependency...

What I would like to do specifically is to make a material property dependent on the heat flux for conducting materials. Also here a circular dependency arises. Although, if a heat flux throughout the geometry would be known beforehand, the material property can be calculated and the next iteration of heat flux too...

So has anyone figured out how to solve implicit equations like that?
Has anyone found a solution to this problem? I struggle with the same problem and I think it is quite fundamental to be able to solve such systems of equations. I suppose it should be possible, since even with a simple algorithm for 1D cases you should be able to do it "by hand" in a spreadsheat program. The comment Ivar gave, to use the time discrete solver and use the "prev" command has not worked for me sofar. I suppose it still has to do with initialization of the problem, since I still get circular variable dependency... What I would like to do specifically is to make a material property dependent on the heat flux for conducting materials. Also here a circular dependency arises. Although, if a heat flux throughout the geometry would be known beforehand, the material property can be calculated and the next iteration of heat flux too... So has anyone figured out how to solve implicit equations like that?

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 24 janv. 2011, 09:31 UTC−5
Hi

for me you have: at(), with(), prev() and global variables (see the KB for adding time dependent variables) and this should allow to do about everything.

Have you tried to set up your physics in stationary, driven by an ODE in transient, and defining a global equation in the ODE section to get your derivative and your new variable at the "new step" ?

in V4.1 this is rather straigthforward. Far more complex via matlab in 3.5

--
Good luck
Ivar
Hi for me you have: at(), with(), prev() and global variables (see the KB for adding time dependent variables) and this should allow to do about everything. Have you tried to set up your physics in stationary, driven by an ODE in transient, and defining a global equation in the ODE section to get your derivative and your new variable at the "new step" ? in V4.1 this is rather straigthforward. Far more complex via matlab in 3.5 -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 22 juin 2011, 05:29 UTC−4
Hi,

At() and With() operators have the time variable as an argument.

If I want to evaluate an expression at a certain condition instead of time... for example: I want the solution of variable "u" when the Temperature "T" = 400 K ?

How could I get through this, is it by searching for the value of "t" at which T=400 K ?
Same question applies to Prev operator where I want to know the number of iteration at which T=400K.

Best Regards
--
Ali
(4.0a)
Hi, At() and With() operators have the time variable as an argument. If I want to evaluate an expression at a certain condition instead of time... for example: I want the solution of variable "u" when the Temperature "T" = 400 K ? How could I get through this, is it by searching for the value of "t" at which T=400 K ? Same question applies to Prev operator where I want to know the number of iteration at which T=400K. Best Regards -- Ali (4.0a)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30 août 2011, 11:11 UTC−4
Hi:

I tried the prev() separator in V4 version to get the previous value of i to calculate eta, however, there is the error information 'circular variable depending detected", It seems if I want to calculate i as a equation related to the value of i from the previous step, I can not do it in V4. Do you have any suggestion about this? Or will it be solved in the higher version like V4.2?

Thanks

Wei Wu
Hi: I tried the prev() separator in V4 version to get the previous value of i to calculate eta, however, there is the error information 'circular variable depending detected", It seems if I want to calculate i as a equation related to the value of i from the previous step, I can not do it in V4. Do you have any suggestion about this? Or will it be solved in the higher version like V4.2? Thanks Wei Wu

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30 août 2011, 22:13 UTC−4
Hi,

Try incorporating your variables into a system of PDE's (adequately i'd use a general form) where you put to zero all the coefficients ( or matrices) then use the source term (f) to implement your equations. There is a topic explaining this along with the prev() and bdf() operators.

I hope this answers your question
--
Regards
Hi, Try incorporating your variables into a system of PDE's (adequately i'd use a general form) where you put to zero all the coefficients ( or matrices) then use the source term (f) to implement your equations. There is a topic explaining this along with the prev() and bdf() operators. I hope this answers your question -- Regards

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 31 août 2011, 10:55 UTC−4
Hi:

Thanks very much for your reply. Actually what I use in my model is PDE general form. And what I want to solve is very fundemental:

eta = V - U - i*R

i = i0*exp(eta*k)

considering the iteration, so I use the prev() function:

eta = V - U - i_prev*R

i = i0*exp(eta*k)

i_prev=if(t>10, prv(i,1),0)

So the previous step value of i need to be used to calculate the current i value.

However, it doesn't work.

I think bdf() is not appropriate at here, as it gives the value of deriviation at the previous time. What I want is only the value from the previous time step.

Do you have other idea about my situation?

Best

Wei Wu



Hi: Thanks very much for your reply. Actually what I use in my model is PDE general form. And what I want to solve is very fundemental: eta = V - U - i*R i = i0*exp(eta*k) considering the iteration, so I use the prev() function: eta = V - U - i_prev*R i = i0*exp(eta*k) i_prev=if(t>10, prv(i,1),0) So the previous step value of i need to be used to calculate the current i value. However, it doesn't work. I think bdf() is not appropriate at here, as it gives the value of deriviation at the previous time. What I want is only the value from the previous time step. Do you have other idea about my situation? Best Wei Wu

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 31 août 2011, 12:04 UTC−4
Hi,

What are the initial conditions you used ?

If u can send a copy of your model or a picture on how you implemented the system, it s more useful.
Hi, What are the initial conditions you used ? If u can send a copy of your model or a picture on how you implemented the system, it s more useful.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 17 avr. 2012, 08:08 UTC−4
Hi,

I need help with the circular dependency as well.
I want conductivity which is

Sigma=(1e10)*(1e8[A/m^2]/mf.normJ)^(-10)[S/m]

However, the equation for External current density is
Je=sigma*dA/dt+..
and clearly normJ depends on Je, so I get the circular dependency error.

how can I define it well? have you solved this problem before?
I have attached my model.

Thank you,
Shoval (I'm using 4.2a)
Hi, I need help with the circular dependency as well. I want conductivity which is Sigma=(1e10)*(1e8[A/m^2]/mf.normJ)^(-10)[S/m] However, the equation for External current density is Je=sigma*dA/dt+.. and clearly normJ depends on Je, so I get the circular dependency error. how can I define it well? have you solved this problem before? I have attached my model. Thank you, Shoval (I'm using 4.2a)


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18 avr. 2012, 09:44 UTC−4
The easiest solution I have found is to copy your governing equations (doubling the amount of dependent variables) and use a segregated solver. This way you calculate the initial conditions for your problem with a second set of equations, bypassing the circular dependency. There are however more elegant ways to solve your problem. For simulations of current distributions in superconductors (where the resistivity is dependent on the current density and vice versa) the H-formulation offers a nice solution. I remember vaguely that for version 3.5 there was a nice example explaining how to avoid (or rather bypass) this circular dependency.

I hope that helps,

- Erwin
The easiest solution I have found is to copy your governing equations (doubling the amount of dependent variables) and use a segregated solver. This way you calculate the initial conditions for your problem with a second set of equations, bypassing the circular dependency. There are however more elegant ways to solve your problem. For simulations of current distributions in superconductors (where the resistivity is dependent on the current density and vice versa) the H-formulation offers a nice solution. I remember vaguely that for version 3.5 there was a nice example explaining how to avoid (or rather bypass) this circular dependency. I hope that helps, - Erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18 avr. 2012, 09:50 UTC−4
Hi,
using a segregated solver is something I can do, but what do you mean by copt my equations? what do I do with them?


Can you tell me which example from 3.5 it is? If it is possible in 3.5 it must be in 4.2a...

Thank you,
Shoval
Hi, using a segregated solver is something I can do, but what do you mean by copt my equations? what do I do with them? Can you tell me which example from 3.5 it is? If it is possible in 3.5 it must be in 4.2a... Thank you, Shoval

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18 avr. 2012, 11:20 UTC−4
Dear Shoval,

I do not recall exactly which example this was, this you will need to look up yourself. It has to do with exploiting the Maxwell equations fully and add an additional variable to avoid the circular dependency.

Maybe this helps you better:
Difficulty:
Voltage=Current*Resistance, but resistance is function of current density -> circular dependency
Solution:
Add a new equation (instead of copying your original one as I wrote before): help_variable=J with initial conditions equal to your homogeneous boundary condition for Je.
Make resistance (or rather conductivity) a function of this new variable: R(help_variable).

Since help_variable is a dependent variable, it has its own initial condition and thus can be inserted in the function for the resistivity. The voltage and current are now calculated by your original equation. This solution bypasses the circular dependency for some specific cases, this is a very blunt method... For superconductors the physics is more complicated, look for example for H-formulation to see how correct current distributions can be calculated effectively with COMSOL.

Cheers and good luck,

- Erwin
Dear Shoval, I do not recall exactly which example this was, this you will need to look up yourself. It has to do with exploiting the Maxwell equations fully and add an additional variable to avoid the circular dependency. Maybe this helps you better: Difficulty: Voltage=Current*Resistance, but resistance is function of current density -> circular dependency Solution: Add a new equation (instead of copying your original one as I wrote before): help_variable=J with initial conditions equal to your homogeneous boundary condition for Je. Make resistance (or rather conductivity) a function of this new variable: R(help_variable). Since help_variable is a dependent variable, it has its own initial condition and thus can be inserted in the function for the resistivity. The voltage and current are now calculated by your original equation. This solution bypasses the circular dependency for some specific cases, this is a very blunt method... For superconductors the physics is more complicated, look for example for H-formulation to see how correct current distributions can be calculated effectively with COMSOL. Cheers and good luck, - Erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 avr. 2012, 10:44 UTC−4
Dear Erwin,

I have not managed to perform what you wrote with the help_variable. perhaps I misunderstood you.
I looked at the model library and found the Superconducting Wire model; it uses the general-form PDE mathematics. is this the one you meant? Even after reading it and attempting to understand and rebuild it, I do not understand how this can solve my problem.

Help?

Thank you,
Shoval
Dear Erwin, I have not managed to perform what you wrote with the help_variable. perhaps I misunderstood you. I looked at the model library and found the Superconducting Wire model; it uses the general-form PDE mathematics. is this the one you meant? Even after reading it and attempting to understand and rebuild it, I do not understand how this can solve my problem. Help? Thank you, Shoval

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.