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.

Coupling linear driving force model, mass balance and energy balance

Please login with a confirmed email address before reporting spam

Hello!

I am making an adsorption model only using pde interfaces where I am solving the linear driving force model, mass balance and energy balance for the same system. My question is how I couple the three equations, as the linear driving force model is included in the source term of the two balance equations, but I am not allowed to use one dependent variable in another pde equation set.

Is the solution to make a global variable for the one solved with the linear driving force model?

Thank you for any help!


5 Replies Last Post 4 mai 2022, 11:41 UTC−4
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 14 avr. 2022, 11:42 UTC−4

Hi Nora,

It is possible, in general, to use a variable from one physics interface in another. Because you mentioned working on adsorption, I suspect the issue may be the scope of the variables. Perhaps some variables are defined only on some entities and you're trying to call them on another entity, perhaps one of a different dimension. The solution may be to use coupling operators. But it's hard to tell without knowing the specifics of the mathematical problem you want to solve. Can you provide that info? Also, this adsorption and transport model could be helpful to you.

Best,

Jeff

-------------------
Jeff Hiller
Hi Nora, It is possible, in general, to use a variable from one physics interface in another. Because you mentioned working on adsorption, I suspect the issue may be the scope of the variables. Perhaps some variables are defined only on some entities and you're trying to call them on another entity, perhaps one of a different dimension. The solution may be to use coupling operators. But it's hard to tell without knowing the specifics of the mathematical problem you want to solve. Can you provide that info? Also, [this adsorption and transport model](https://www.comsol.com/model/transport-and-adsorption-5) could be helpful to you. Best, Jeff

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 4 mai 2022, 10:05 UTC−4

Hi,

Thank you for your help!

I was able to solve the issue I had, but I am now wondering about something else. I am still solving the mass and energy balance equations, but I also want to update the velocity after each time step. Do you know how I could most easily implement an equation that does this timestep update of the velocity? Would it be creating a global function, or perhaps solving it as a global ODE/DAE from the math interface? I have read about the operator p(expr, i). As I understood it, this gives the value of expr in the timestep i before the current timestep? I am attaching a photo of the equation I want to implement. F is the variable I want to update, and Ct and Tf are dependent variables from the mass and energy balance equations respectively. The variable will then be used in both the mass and energy balance equation as the convection coefficient beta.

I tried to implement it as a global ODE/DAE, but COMSOL did not recognize the dependent variables from the already implemented mass and energy balance equations.

Best, Nora

Hi, Thank you for your help! I was able to solve the issue I had, but I am now wondering about something else. I am still solving the mass and energy balance equations, but I also want to update the velocity after each time step. Do you know how I could most easily implement an equation that does this timestep update of the velocity? Would it be creating a global function, or perhaps solving it as a global ODE/DAE from the math interface? I have read about the operator p(expr, i). As I understood it, this gives the value of expr in the timestep i before the current timestep? I am attaching a photo of the equation I want to implement. F is the variable I want to update, and Ct and Tf are dependent variables from the mass and energy balance equations respectively. The variable will then be used in both the mass and energy balance equation as the convection coefficient beta. I tried to implement it as a global ODE/DAE, but COMSOL did not recognize the dependent variables from the already implemented mass and energy balance equations. Best, Nora


Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 4 mai 2022, 10:23 UTC−4
Updated: 3 years ago 4 mai 2022, 10:23 UTC−4

Hello Nora,

Your image, it seems, reflects some form of discrete timestepping (with "new" and "prev" referencing two different times). Usually in COMSOL the user should implement equations in their underlying time-as-a-continuum form, and leave the time stepping to the software.

Best,

Jeff

-------------------
Jeff Hiller
Hello Nora, Your image, it seems, reflects some form of discrete timestepping (with "new" and "prev" referencing two different times). Usually in COMSOL the user should implement equations in their underlying time-as-a-continuum form, and leave the time stepping to the software. Best, Jeff

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 4 mai 2022, 10:43 UTC−4

Hello again,

Thank you for your quick reply!

Yes the equation is in this form to use less computing resources asociated with updating the value, and is more used to couple the energy and mass balance equations. Is it possible to implement it this way in COMSOL?

If I then instead implement the equation for the flow in the time-as-a-continuum form, what interface can I use in order to use the dependent variables of the other equations as arguments in the flow equation?

Best, Nora

Hello again, Thank you for your quick reply! Yes the equation is in this form to use less computing resources asociated with updating the value, and is more used to couple the energy and mass balance equations. Is it possible to implement it this way in COMSOL? If I then instead implement the equation for the flow in the time-as-a-continuum form, what interface can I use in order to use the dependent variables of the other equations as arguments in the flow equation? Best, Nora

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 4 mai 2022, 11:41 UTC−4
Updated: 3 years ago 4 mai 2022, 15:45 UTC−4

For various reasons, I wouldn't presume that the time-discrete approach actually will use less computing resources if you take control of the timestepping, nor that it would be more likely to converge to the correct solution.

Which interface to use depends on the nature of the equation you need to solve. Different interfaces are available for equations that are distributed spatially vs global, and for ODEs vs PDEs. You can obviously use the most general interfaces (those for spatially distributed PDEs) to handle the simplest case (global ODE), but you'd be wasting resources by storing duplicate data, so you usually use the interface that's "just right" for your situation. It's not clear to me from your image what case you're in. I'll try and guess.

My first interpretation of your earlier comment that "I tried to implement it as a global ODE/DAE, but COMSOL did not recognize the dependent variables" is that your underlying equation is a global one (ie. there is a single value of F that needs to be computed for the entire model at each time; F does not vary in space), but that you got an error because you tried to include in it terms that vary spatially. Either your equation is distributed (and can call variables that vary spatially) or it's not and it can't (at least not directly. This takes me back to my initial comment that coupling operators may be part of the solution (because they can be used to reduce the spatial dimensionality of variables by computing integrals, averages, etc, and can make data available elsewhere in the model)). If my guess is correct, then see Reference Manual, version 6.0, page 1233 and following.

A second possible interpretation of your earlier comment is that despite the fact that your underlying equation is distributed (F should vary over space and depend on other quantities that vary in space) you tried to enter it through an interface meant for for solving global equations. If that second interpretation is correct, then see Reference Manual, version 6.0, page 1154 and following.

Best,

Jeff

PS: I hope this is clear enough. COMSOL is very flexible and in a 3D model allows you to set up equations defined on 0D entities, 1D entities (which don't have to be straight segments), 2D entities (which don't have to be flat surfaces, as illustrated by this example ) and 3D entities. I glossed over the intermediary dimensions (1D and 2D) above, but they may be of significance in your model since you are working with adsorption.

-------------------
Jeff Hiller
For various reasons, I wouldn't presume that the time-discrete approach actually will use less computing resources if you take control of the timestepping, nor that it would be more likely to converge to the correct solution. Which interface to use depends on the nature of the equation you need to solve. Different interfaces are available for equations that are distributed spatially vs global, and for ODEs vs PDEs. You can obviously use the most general interfaces (those for spatially distributed PDEs) to handle the simplest case (global ODE), but you'd be wasting resources by storing duplicate data, so you usually use the interface that's "just right" for your situation. It's not clear to me from your image what case you're in. I'll try and guess. My first interpretation of your earlier comment that "I tried to implement it as a global ODE/DAE, but COMSOL did not recognize the dependent variables" is that your underlying equation is a global one (ie. there is a single value of F that needs to be computed for the entire model at each time; F does not vary in space), but that you got an error because you tried to include in it terms that vary spatially. Either your equation is distributed (and can call variables that vary spatially) or it's not and it can't (at least not directly. This takes me back to my initial comment that coupling operators may be part of the solution (because they can be used to reduce the spatial dimensionality of variables by computing integrals, averages, etc, and can make data available elsewhere in the model)). If my guess is correct, then see Reference Manual, version 6.0, page 1233 and following. A second possible interpretation of your earlier comment is that despite the fact that your underlying equation is distributed (F should vary over space and depend on other quantities that vary in space) you tried to enter it through an interface meant for for solving global equations. If that second interpretation is correct, then see Reference Manual, version 6.0, page 1154 and following. Best, Jeff PS: I hope this is clear enough. COMSOL is very flexible and in a 3D model allows you to set up equations defined on 0D entities, 1D entities (which don't have to be straight segments), 2D entities (which don't have to be flat surfaces, as illustrated by [this example](https://www.comsol.com/model/shell-diffusion-in-a-tank-222) ) and 3D entities. I glossed over the intermediary dimensions (1D and 2D) above, but they may be of significance in your model since you are working with adsorption.

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.