Dave Greve
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月29日 GMT+1 18:41
Updated:
10 months ago
2023年10月29日 GMT+1 18:43
This sort of equation can be solved in a Global ODE physics, because after all an algebraic equation is a special case of a differential equation.
There will be multiple roots. You will need to choose initial conditions to get the one you want.
This sort of equation can be solved in a Global ODE physics, because after all an algebraic equation is a special case of a differential equation. There will be multiple roots. You will need to choose initial conditions to get the one you want.
Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月29日 GMT+1 18:42
Updated:
10 months ago
2023年10月29日 GMT+1 18:43
Hi,
you can set up an algebraic equation to solve for q. Check the documentation and examples for the equations interface. Those are very powerful tools in COMSOL.
Cheers Edgar
Dave was quicker
-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi, you can set up an algebraic equation to solve for q. Check the documentation and examples for the equations interface. Those are very powerful tools in COMSOL. Cheers Edgar Dave was quicker
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月30日 GMT+1 09:49
Updated:
10 months ago
2023年10月30日 GMT+1 09:50
Thank you for the responses. Do I need to add the algebraic equations using matlab or they can be solely solved in COMSOL. I found one solution using MATLAB equations in COMSOL. Is there a way to solve without using MATLAB equations?
Thank you for the responses. Do I need to add the algebraic equations using matlab or they can be solely solved in COMSOL. I found one solution using MATLAB equations in COMSOL. Is there a way to solve without using MATLAB equations?
Lars Gregersen
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月30日 GMT+1 10:32
You shouldn't use Matlab for this. Just add the equstion to your Comsol model and the Comsol solvers will solve this equation together with the rest of your physics.
-------------------
Lars Gregersen
Comsol Denmark
You shouldn't use Matlab for this. Just add the equstion to your Comsol model and the Comsol solvers will solve this equation together with the rest of your physics.
Magnus Ringh
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月30日 GMT+1 10:36
Hi Hina,
No, there is no need to use MATLAB. As Dave and Edgar mentioned, you can set up this algebraic equation using aGlobal ODEs and DAEsinterface with aGlobal Equationsnode, where you solve forq
using a general algebraic equationsf(q, qt, qtt, t)
. You can also define the contantsk
,a
,b
, andc
using aParametersnode in the COMSOL Desktop.
Best regards,
Magnus
Hi Hina, No, there is no need to use MATLAB. As Dave and Edgar mentioned, you can set up this algebraic equation using a **Global ODEs and DAEs** interface with a **Global Equations** node, where you solve for `q` using a general algebraic equations `f(q, qt, qtt, t)`. You can also define the contants `k`, `a`, `b`, and `c` using a **Parameters** node in the COMSOL Desktop. Best regards, Magnus
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月30日 GMT+1 13:00
Updated:
10 months ago
2023年10月30日 GMT+1 13:04
Thank you Magnus for the clear explanation. As suggested, I added Global ODEs and DAEs interface and a Global Equations node. I wrote my equation as c1-(q/k)exp(aq+bq^2+cq^3). I have to calculate 'q' from this equation and the value of 'c1' is caluclated from the solver which is being used to obtain 'q'. Other parameters k, a, b and c are given as constant. While implementing the interface and computing the model it is giving me an 'undefined variable' error for 'c1'. Do you have some idea where I am going wrong.
Thank you Magnus for the clear explanation. As suggested, I added Global ODEs and DAEs interface and a Global Equations node. I wrote my equation as c1-(q/k)*exp(a*q+b*q^2+c*q^3). I have to calculate 'q' from this equation and the value of 'c1' is caluclated from the solver which is being used to obtain 'q'. Other parameters k, a, b and c are given as constant. While implementing the interface and computing the model it is giving me an 'undefined variable' error for 'c1'. Do you have some idea where I am going wrong.
Jeff Hiller
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月30日 GMT+1 19:30
Updated:
10 months ago
2023年10月30日 GMT+1 19:29
It sounds like c1 varies in space. In that case, use a Domain ODE and DAE.
Jeff
-------------------
Jeff Hiller
It sounds like c1 varies in space. In that case, use a Domain ODE and DAE. Jeff
Magnus Ringh
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年10月31日 GMT+1 10:27
Hi Hina,
Yes, it's either as Jeff suggests above, or elsec1
cannot be a field variable (space-dependent variable) in a global DAE, but it can be a scalar function of time, such as an average value, using anAveragenonlocal coupling variable, or a value in a point in the geometry. Also, if you want to add units for the DAE, make sure to "dedimensionalize"c1
in the expression for the exponent.
Best regards, Magnus
Hi Hina, Yes, it's either as Jeff suggests above, or else `c1` cannot be a field variable (space-dependent variable) in a global DAE, but it can be a scalar function of time, such as an average value, using an **Average** nonlocal coupling variable, or a value in a point in the geometry. Also, if you want to add units for the DAE, make sure to "dedimensionalize" `c1` in the expression for the exponent. Best regards, Magnus
Please login with a confirmed email address before reporting spam
Posted:
10 months ago
2023年11月1日 GMT+1 09:32
Updated:
10 months ago
2023年11月1日 GMT+1 13:53
Thank you Jeff and Magnus for the suggestions. Yes you are right that c1 varies in space. I was able to solve my problem using 'Domain ODE and DAE' interface and am able to obtain q1 using the value cp1 calculated from the solver for this equation
cp1-(q1/k1)exp(a1q1+b1q1^2+c1*q1^3)=0
Now second part of my problem is that I have to solve two equations simultaneously and obtain two unknowns. The equations are like:
cp1-(q1/k1)exp(a1q1+b1q1^2+c1*q1^3)=0
and
cp2-(q2/k2)exp(a2q1+b2q2^2+c2*q2^3)=0
The parameters k1,a1,b1,c1, k2,a2,b2,c2 are known. cp1 and cp2 are calculated from the solver which are used to solve the above two eqns and obtain q1 and q2. When I am using two equations simultaneously I am getting an error that 'Nonlinear solver did not converge.' Can you please guide me in this? I am able to solve the above two equations in MATLAB and obtain values for q1 and q2.
Thank you Jeff and Magnus for the suggestions. Yes you are right that c1 varies in space. I was able to solve my problem using 'Domain ODE and DAE' interface and am able to obtain q1 using the value cp1 calculated from the solver for this equation cp1-(q1/k1)exp(a1*q1+b1*q1^2+c1*q1^3)=0 Now second part of my problem is that I have to solve two equations simultaneously and obtain two unknowns. The equations are like: cp1-(q1/k1)exp(a1*q1+b1*q1^2+c1*q1^3)=0 and cp2-(q2/k2)exp(a2*q1+b2*q2^2+c2*q2^3)=0 The parameters k1,a1,b1,c1, k2,a2,b2,c2 are known. cp1 and cp2 are calculated from the solver which are used to solve the above two eqns and obtain q1 and q2. When I am using two equations simultaneously I am getting an error that 'Nonlinear solver did not converge.' Can you please guide me in this? I am able to solve the above two equations in MATLAB and obtain values for q1 and q2.