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 relate two variables?
Posted May 13, 2011, 2:56 p.m. EDT Chemical Reaction Engineering, Parameters, Variables, & Functions, Studies & Solvers Version 4.1, Version 4.3 18 Replies
Please login with a confirmed email address before reporting spam
I have a quick question. I'm using the transport of diluted species module, and I have two species in my solution (c1 and c2). I want COMSOL to know that c1*c2=1e-8[unit] at all times during the calculation. How should I do this? I already set the initial value for both is 1e-4[unit].
I tried to put such relationship in local variables (i.e. c2=1e-8/c1, with units), but I kept getting error message "duplicate variable name"
I've attached a simple case with such problems.
Any help is greatly appreciated.
Attachments:
Please login with a confirmed email address before reporting spam
comsols equation analyser expects the equation to be written as my_expression =0, sou you should start to rewrite xour equation in that way i.e. c1*c2-1E-8 = 0, and not normalise to "1"
Check the doc for global equations
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Hi
comsols equation analyser expects the equation to be written as my_expression =0, sou you should start to rewrite xour equation in that way i.e. c1*c2-1E-8 = 0, and not normalise to "1"
Check the doc for global equations
--
Good luck
Ivar
Thanks Ivar,
I tried adding this to the global equation under ODE and DAE: c1*c2-1e-8, at the blank that says f(u,ut,utt,t). I tried both with unit or without, and both with initial contions at the following blanks or leaving the initial conditions emipy. But no matter what I try, it always gave me this error message:
Failed to evaluate variable.
- Variable: mod1.c1
- Global scope
Failed to evaluate expression.
- Expression: mod1.c1
I'm attaching the test file so you can see. Your help is greatly appreciated!
Attachments:
Please login with a confirmed email address before reporting spam
Hi
comsols equation analyser expects the equation to be written as my_expression =0, sou you should start to rewrite xour equation in that way i.e. c1*c2-1E-8 = 0, and not normalise to "1"
Check the doc for global equations
--
Good luck
Ivar
Thanks Ivar,
I tried adding this to the global equation under ODE and DAE: c1*c2-1e-8, at the blank that says f(u,ut,utt,t). I tried both with unit or without, and both with initial contions at the following blanks or leaving the initial conditions emipy. But no matter what I try, it always gave me this error message:
Failed to evaluate variable.
- Variable: mod1.c1
- Global scope
Failed to evaluate expression.
- Expression: mod1.c1
I'm attaching the test file so you can see. Your help is greatly appreciated!
Hi,
I encountered the same problem when I use the global equation.
I think maybe the reason is that what the global equation need is global variable, but in your model, c1 and c2 are both local variables.
However, I don't know how to transform a local variable to a global variable. I am trying---
Please login with a confirmed email address before reporting spam
basically a global variable is independent of any "Entity", while most local variables depend (implicitly that is one of the difficulties in COMSOL to identify when and why, but it's plain math and physics) so mostly you should integrate or average out the variable to make it independent of x,y,z or r, or T(x,y,z ...) etc (the dependency might be several levels deep
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Hi
basically a global variable is independent of any "Entity", while most local variables depend (implicitly that is one of the difficulties in COMSOL to identify when and why, but it's plain math and physics) so mostly you should integrate or average out the variable to make it independent of x,y,z or r, or T(x,y,z ...) etc (the dependency might be several levels deep
--
Good luck
Ivar
Hi Ivar, thanks a lot for your response. I'm not quite sure that I understand what you mean by integrate or average out the variables to make it independent of xyz. What I have here are two variables for concentration of two diluted species, which are not dependent of xyz. All I want to do is to somehow link these two in a way that the multiply is always a constant. I believe it should not be that hard:)
I tried to put c2=1e-8/c1 in local variables. I don't understand why that does not get registered.
Thanks.
--
Wei Wang, Ph.D. Candidate
Malloup group, Penn State
Please login with a confirmed email address before reporting spam
I believe you are getting confused by the "implicit" notation of COMSOL:
your c1 and c2 are dependent variables!
hence they are in fact what I call a "field" and not a simple "variable". they are of the type c1(x,y,z) and c2(x,y,z) as their value might vary over the total area = domain in 2D you are considering.
So if you write out c1*c2-1E-8=0 in your global ODE, COMSOL does not know for which "point" (x,y,z) over the domain it should consider.
In fact your c1, c2 (even if they look so) are NOT any Global variable that can be considered as a constant for itself.
You mean perhaps that the TOTAL concentration product C1*C2 (note the upper case I have chosen arbitrarily) where C1=intop1(c1) and C2=intop1(c2) are constant ?
where intop1() is the integration operand over your domain
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I am still trying to relate two variables in two different multiphysics.
It would be great if someone has a lead of how to do it.
Thank you,
Jo
Please login with a confirmed email address before reporting spam
but can't you use the mapping operators then ? (Definition node)
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Hi
I believe you are getting confused by the "implicit" notation of COMSOL:
your c1 and c2 are dependent variables!
hence they are in fact what I call a "field" and not a simple "variable". they are of the type c1(x,y,z) and c2(x,y,z) as their value might vary over the total area = domain in 2D you are considering.
So if you write out c1*c2-1E-8=0 in your global ODE, COMSOL does not know for which "point" (x,y,z) over the domain it should consider.
In fact your c1, c2 (even if they look so) are NOT any Global variable that can be considered as a constant for itself.
You mean perhaps that the TOTAL concentration product C1*C2 (note the upper case I have chosen arbitrarily) where C1=intop1(c1) and C2=intop1(c2) are constant ?
where intop1() is the integration operand over your domain
--
Good luck
Ivar
Hi Ivar,
That clarification cleared up some confusion for me. In fact when I said c1 and c2 I meant concentration for every single point, i.e. at each point of the domain I need the multiply of c1 and c2 to be a constant, even though the number of c1 and c2 will vary at different points of the domain. I hope that sounds clear to me.
I'm still a little confused about how that should be done.
Thanks for your help.
--
Wei Wang, Ph.D. Candidate
Malloup group, Penn State
Please login with a confirmed email address before reporting spam
Thanks.
--
Wei Wang, Ph.D. Candidate
Malloup group, Penn State
Please login with a confirmed email address before reporting spam
I cannot find the mapping operator under Definitions node. Would you please explain that more clearly?
Thank you,
Wei, yes, I think we have very similar problem. Hope we can find our way out soon!
Please login with a confirmed email address before reporting spam
My fault, I used the wrong therm, look after
Definitions - Model Couplings - Extrusion and Projection (depends on what you want to do, see the doc)
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I tried to use extrusion coupling variable. I still can not set an equation that the multiplication of two variables (c1*c2) equals to a constant. I thought the variables will turn into global variables through extrusion coupling, and I can use them in the global equation. But it seems not to work that way.
Any feedback is appreciated.
Thank you!
Jo
Please login with a confirmed email address before reporting spam
Thanks Ivar.
I tried to use extrusion coupling variable. I still can not set an equation that the multiplication of two variables (c1*c2) equals to a constant. I thought the variables will turn into global variables through extrusion coupling, and I can use them in the global equation. But it seems not to work that way.
Any feedback is appreciated.
Thank you!
Jo
What's your settings for the extrusion?
Please login with a confirmed email address before reporting spam
Thanks for your quick reply.
I have made the following simple model: 2D axi-symmetric application mode, I have two variables c_1 and c_2 both controlled only by diffusion and I want COMSOL knows that c_1*c_2=constant. For this I use the "Extrusion Coupling Variables - Subdomain Variables" I select the source subdomain "1", define a Name i.e. C1 and an expression c_1 for the concentration gradient as defined on this domain; also define a NAME C2 and an expression c_2. I select "General transformation" and use "x=r and y=z" as source transformation variable. Then I select the destination tab: select "Level": "subdomain" , I tick and select subdomain "1" and tick "use selected subdomains as destination". Then I give a unknown variable R for the reaction rate for both diffusion equation and I use "global equations". I select "state" Name(u) is R and equation f(u, ut, utt, t)=0 is C1*C2-constant.
But I got a message saying that "fail to evaluate C1 variable"
If somone knows where would be the problem source, please do let me know.
Thank you,
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
Instead, you have to let the condition not be satisfied, and then use negative feedback to get rid of the discrepency. For example, you can have a variable
EXTRA = c1*c2-1e-8
then incorporate EXTRA into the diffusion equation as a reaction rate that destroys some of the c1 and/or c2 if there's too much, or creates extra c1 and/or c2 if there's too little. Then if you solve everything you may not get exactly EXTRA=0, but if you increase the feedback (multiply EXTRA by a large factor in the reaction rate), you can get very close.
This is what happens in real chemical equilibria: Equilibrium happens because the forward and reverse reaction rates depend on the concentrations, always pushing them towards equilibrium in a feedback loop.
Please login with a confirmed email address before reporting spam
I have following four reactions and want to model them as equilibrium reactions in the "transport of diluted species" interface;
r1: H2O<=>H++OH-
r2: CO2aq+H2O<=>H++HCO3-
r3: HCO3-<=>H++CO3--
r4: Na++HCO3-<=>NaHCO3aq
I need guidance about how to set equilibrium reactions within "transport of diluted species" interface. Attached is mph file to have a look how I tried to define these equilibrium reactions in the form of algebraic relations.
Solution converges for specified initial and boundary conditions. However, I am not sure about the formulation of equilibrium reactions in COMSOL.
Best Regards,
Nawaz Ahmad
KTH
Attachments:
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.
Suggested Content
- BLOG Analyze Thin Structures Using Up and Down Operators
-
KNOWLEDGE BASE
How can I see the equations COMSOL is defining?
How do I implement a user-defined Multiphysics coupling? - FORUM Issue in solving for variables in a two-study problem
- FORUM Representation of two variables in a plot
- FORUM Inquiry on Modeling Two PDEs with Three Dependent Variables in COMSOL