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 transmit solution data between two models?

Please login with a confirmed email address before reporting spam

Hello!
How to transmit solution data between two models?
I have set up two models as follows.
1. To solve u1 satisfied the PDE, D1(u1)=f1, in the first model;
2. to solve u2 satisfied the PDE, D2(u2)=u1, in the second model.
I try to transmit the data of u1 by interpolation function by the following steps.
1. Solve u1 in the first model and save u1 in text file, u1.txt, in the formate described in the help document for interpolation function;
2. create interpolation function, u1, in the second model from the text file, u1.txt, and then solve u2.
This solution does work, but the problem is time consuming by writing and reading data of u1, because in 3D model, there are many many interpolation points.
In my opinion, the solution data of u1 interpolated by regular interpolation points may lead to accurracy lossing. Another question is how to transmit the solution between model in the form of mesh nodes.
--
Computational Electromagnetics, Finite Element Method, Computer Aided Engineering.

8 Replies Last Post 28.02.2014, 04:33 GMT-5
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 16.06.2012, 06:05 GMT-4
Hi

I do not really follow you : why does a dump of dependent values on mesh nodes in one model, mapped to another mesh node distribution in another model, be MORE precise than using regular grid interpoalted values ?

On the other hand, I agree that transferring data points for larger models via txt files is cumbersome.
Therefore I mostly run one or 2 models in the same model file (but I use mostly 2 models only if the geometry is different, as in one model one can have several studies, several different or similar physics, one or several meshes and it's easy to mix all, including referencing one physics or PDE to another via the variables. Then COMSOl looks after the node mapping. And I find it more precise (while not having any quantitative measure, really to say its better) to use the same mesh.

Its true this approach is far easier in v4 than 3.5, and the BC related study sequences, coming in 4.3, will make life far easier

--
Good luck
Ivar
Hi I do not really follow you : why does a dump of dependent values on mesh nodes in one model, mapped to another mesh node distribution in another model, be MORE precise than using regular grid interpoalted values ? On the other hand, I agree that transferring data points for larger models via txt files is cumbersome. Therefore I mostly run one or 2 models in the same model file (but I use mostly 2 models only if the geometry is different, as in one model one can have several studies, several different or similar physics, one or several meshes and it's easy to mix all, including referencing one physics or PDE to another via the variables. Then COMSOl looks after the node mapping. And I find it more precise (while not having any quantitative measure, really to say its better) to use the same mesh. Its true this approach is far easier in v4 than 3.5, and the BC related study sequences, coming in 4.3, will make life far easier -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 21.06.2012, 10:52 GMT-4
Hello:
My problem is similar to that described above. I can not figure out how to properly link two study steps that should be sequential in time. To test this I've tried two models both with the 0D Global ODE physics and solving the equations At-0.1 and At-0.2 (dA/dt = 0.1 and dA/dt=0.2.) over the time periods 0-1 and 1-2 respectively. Should be dirt simple and give a line with "kink" at t=1.

I've tried many different configurations for the solver, tried to initialized the second step with the saved solution of the first step, disabling the first study step or the solver etc. Please I need a clear strategy for setting this up. Your help would be greatly appreciated.

Peter
Hello: My problem is similar to that described above. I can not figure out how to properly link two study steps that should be sequential in time. To test this I've tried two models both with the 0D Global ODE physics and solving the equations At-0.1 and At-0.2 (dA/dt = 0.1 and dA/dt=0.2.) over the time periods 0-1 and 1-2 respectively. Should be dirt simple and give a line with "kink" at t=1. I've tried many different configurations for the solver, tried to initialized the second step with the saved solution of the first step, disabling the first study step or the solver etc. Please I need a clear strategy for setting this up. Your help would be greatly appreciated. Peter

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 22.06.2012, 16:38 GMT-4
Hi

it seems that you are unlucky ;) it does not really work for 0D time derivative ODEs.

By trying to understand your remark I noticed: if you use 1D PDE, over a domain 0-1 and 2-3 and define the two PDE as you describe them but using x instead of t, then couple u2 with initial position u1 at common BC point x=1and use 2 stationary solvers, one for each PDE and then solve as is .
Then results are as you expect them, with a kink at x=1 and by default COMSOL links the two cases, adds the stored solution and starts the second stationary case from the first.

But if you do as you describe with 0D and time derivatives, and link u2 from 1-2 sec by using u1 as initial condition, you get all "0" as initial values for u2. The settings of the dependent variables do not work for the time series. By default COMSOL does not add the stored solution, and even if you add it by hand, and link the dependent variables, even by defining when to reload the initial condition, no way with time derivatives

I believe this explains to me why some of my linked time solver cases had oscillations at the stitching time ;)

this seems to be identical in 4.2 and 4.3, at least its coherent

--
Good luck
Ivar
Hi it seems that you are unlucky ;) it does not really work for 0D time derivative ODEs. By trying to understand your remark I noticed: if you use 1D PDE, over a domain 0-1 and 2-3 and define the two PDE as you describe them but using x instead of t, then couple u2 with initial position u1 at common BC point x=1and use 2 stationary solvers, one for each PDE and then solve as is . Then results are as you expect them, with a kink at x=1 and by default COMSOL links the two cases, adds the stored solution and starts the second stationary case from the first. But if you do as you describe with 0D and time derivatives, and link u2 from 1-2 sec by using u1 as initial condition, you get all "0" as initial values for u2. The settings of the dependent variables do not work for the time series. By default COMSOL does not add the stored solution, and even if you add it by hand, and link the dependent variables, even by defining when to reload the initial condition, no way with time derivatives I believe this explains to me why some of my linked time solver cases had oscillations at the stitching time ;) this seems to be identical in 4.2 and 4.3, at least its coherent -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 22.06.2012, 17:59 GMT-4
Ivar:

Thanks for that info. It's often good to know that one is just not missing something obvious.

However I did get it to work partially. I had to set the physics up as two models (mod1 & mod2) and two separate studies each with one time dependent study step corresponding to each of the two time intervals. By setting the initial condition (u_0) for mod2 to "mod1.A", I could get the right result. "A" in this case was the variable used in both models.

Anyhow, I do appreciate the great deal of time you contribute to this forum.

Peter
Ivar: Thanks for that info. It's often good to know that one is just not missing something obvious. However I did get it to work partially. I had to set the physics up as two models (mod1 & mod2) and two separate studies each with one time dependent study step corresponding to each of the two time intervals. By setting the initial condition (u_0) for mod2 to "mod1.A", I could get the right result. "A" in this case was the variable used in both models. Anyhow, I do appreciate the great deal of time you contribute to this forum. Peter

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 23.06.2012, 04:27 GMT-4
Hi

well I'm larning some ting too like this ;)

Indeed if you have two models, you can make a global variable from the first result, and then you will get the right inital condition.
In 0D ODE if you enter a constant value as initial condition for the 2nd time series it works, but that means you know the results of the first run and you use a manual coupling

--
Good luck
Ivar
Hi well I'm larning some ting too like this ;) Indeed if you have two models, you can make a global variable from the first result, and then you will get the right inital condition. In 0D ODE if you enter a constant value as initial condition for the 2nd time series it works, but that means you know the results of the first run and you use a manual coupling -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 26.09.2012, 23:26 GMT-4
Dear All,

Many thanks for this post.

It save my time.

Best regards
Dear All, Many thanks for this post. It save my time. Best regards

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 04.11.2013, 06:45 GMT-5
Hi!

At least in 4.3b one needed to have an Extrusion Coupling between the models.

A translation of the coordinates in one model to the coordinates in the second.

COMSOL support helped me to figure this out.

One first defines a suitable extrusion in the model definitions. (genext1 in this case)

And then uses it, here is an example about magnetization data:
Mx in model 2:
mod1.genext1(mod1.mf.Mx)

I hope I'm at least able to point people to the right direction with this :-)

- Simppa -
Hi! At least in 4.3b one needed to have an Extrusion Coupling between the models. A translation of the coordinates in one model to the coordinates in the second. COMSOL support helped me to figure this out. One first defines a suitable extrusion in the model definitions. (genext1 in this case) And then uses it, here is an example about magnetization data: Mx in model 2: mod1.genext1(mod1.mf.Mx) I hope I'm at least able to point people to the right direction with this :-) - Simppa -

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28.02.2014, 04:33 GMT-5
Hi Ivar,

I am confronted with a difficulty similar to that handled here. I shall want to be able to couple two models so as to use the results of the first one as boundary conditions for the second and then use the results of the second as boundary conditions for the first one and establish so aloop till the end of the simulation time.
Please, can you explain briefly how to do it?
For information I use COMSOL 4.3a

--
Arsene Noume
Hi Ivar, I am confronted with a difficulty similar to that handled here. I shall want to be able to couple two models so as to use the results of the first one as boundary conditions for the second and then use the results of the second as boundary conditions for the first one and establish so aloop till the end of the simulation time. Please, can you explain briefly how to do it? For information I use COMSOL 4.3a -- Arsene Noume

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.