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.

Time- and space-dependent interpolation from data file?

Please login with a confirmed email address before reporting spam

I'm using COMSOL 3.5a. I have a 1D domain and have written my PDEs using the transient diffusion mode from the model navigator.

I wish to create an interpolation function of experimental time-course data using the (Options->Function) tool.

My input file is set up with three columns - a schematic example with a domain length 2:

% time/s x/cm conc/mM
0 0 1
0 1 1
0 2 1
1 0 1
1 1 1.5
1 2 2
.
.
.

I need to create a function conc(x,t) that I can use in my PDEs. However, the Options->Function wizard only seems to allow functions of x (or other spatial dimensions) but not of time.

Is there a way to interpolate from data in a time-dependent manner?

Any help would be appreciated - thanks!

5 Replies Last Post Jul 12, 2010, 10:55 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 7, 2010, 4:01 p.m. EDT
Bump.

Still an open question. Any helpful hints?
Bump. Still an open question. Any helpful hints?

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 Apr 8, 2010, 9:12 a.m. EDT
Hi

if I make a .txt file of this type:

% x y conc
0 0 1
0 1 1
0 2 1
1 0 1
1 1 1.5
1 2 2
2 2 2.5
2 2 3.5
2 3 4
...

I generate a function conc(x,y) where x,y are just placeholders for any variable name

I can then call "conc(t,x)" in a "Postprocessing - Domain Plot Parameter - Line" call either as multiple plots over time with "x" my 1D dimension defined as x-axis variable, or as vertical spread lines showing the min max and extent over time (expression for x-axis) for x_start <= x <= x_end of my 1D sub-domain line going from x_start to x_end

but you need to use x,y,z at most as (dummy) variable name for the function file first line and then followed by the function name that should not contain .-,/+*"&$[]...

hope this helps
Ivar
Hi if I make a .txt file of this type: % x y conc 0 0 1 0 1 1 0 2 1 1 0 1 1 1 1.5 1 2 2 2 2 2.5 2 2 3.5 2 3 4 ... I generate a function conc(x,y) where x,y are just placeholders for any variable name I can then call "conc(t,x)" in a "Postprocessing - Domain Plot Parameter - Line" call either as multiple plots over time with "x" my 1D dimension defined as x-axis variable, or as vertical spread lines showing the min max and extent over time (expression for x-axis) for x_start

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 12, 2010, 11:09 a.m. EDT
Thanks for the feedback Ivar.

You suggested the following approach,
I generate a function conc(x,y) where x,y are just placeholders for any variable name

I can then call "conc(t,x)" in a "Postprocessing - Domain Plot Parameter - Line" call either as multiple plots over time with "x" my 1D dimension defined as x-axis variable, or as vertical spread lines showing the min max and extent over time (expression for x-axis) for x_start <= x <= x_end of my 1D sub-domain line going from x_start to x_end
However, I need to clarify something. Beyond plotting data, I need to be able to hand this function to the solver as a term in my PDEs,

da/dt = f( a(x), conc(t,x) ).

For a static distribution over the x dimension, this requires clicking the "Use space coordinates as default function arguments" in the Functions dialog box to get conc(x). This doesn't work if I use one of the other spatial dimension variables as a placeholder for time.

Also, I may need to generalize this to a full spatial model where I interpolate from data to generate a function conc(t,x,y,z). Is there a way to create such a function that can be used by the solver?

Thanks again!
Thanks for the feedback Ivar. You suggested the following approach, [QUOTE]I generate a function conc(x,y) where x,y are just placeholders for any variable name I can then call "conc(t,x)" in a "Postprocessing - Domain Plot Parameter - Line" call either as multiple plots over time with "x" my 1D dimension defined as x-axis variable, or as vertical spread lines showing the min max and extent over time (expression for x-axis) for x_start

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 Apr 12, 2010, 3:07 p.m. EDT
Hi

There must certainly be, but I must admit I have never tried, but I see the utility. In Matlab you certainly can adapt things easier, but inside the GUI's only, I cannot tell like that. I would have to tweak and try it out myself, and just now I'm stuck on missing general force/torque loads in 3D structural so I'm rather locked on my (paid) job.

Anyhow, for the methodology, I would start trying out on a very simple case with 2-4 input points, in 1,2 then 3 coordinates, and a very simple example first

Have fun Comsoling
Ivar
Hi There must certainly be, but I must admit I have never tried, but I see the utility. In Matlab you certainly can adapt things easier, but inside the GUI's only, I cannot tell like that. I would have to tweak and try it out myself, and just now I'm stuck on missing general force/torque loads in 3D structural so I'm rather locked on my (paid) job. Anyhow, for the methodology, I would start trying out on a very simple case with 2-4 input points, in 1,2 then 3 coordinates, and a very simple example first Have fun Comsoling Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 12, 2010, 10:55 a.m. EDT
Some days ago, I had a problem similar to the one of James: i.e set a time dependent mechanical BC using a time-dependent interpolation of data.
In particular, in my problem I had to assing an acceleration in a certain point of a body and perform a time-domain simulation.
By default Comsol 3.5a (that's the software version I have employed), in several mechanical modules allows to set displacements and not accelerations.

I have solved such a problem in the following way:

- import the data in tabular form (one column is the physical quantity, the other is time) in Comsol
- call this function "data" (this will be, by default, a function of the type "f(x)")
- setup a global equation where the function "data" is written as "data(t)", where t is the usual time variable.

In this way the software "understands" that the independent variable is a time and not a space.

I hope this helps.





Some days ago, I had a problem similar to the one of James: i.e set a time dependent mechanical BC using a time-dependent interpolation of data. In particular, in my problem I had to assing an acceleration in a certain point of a body and perform a time-domain simulation. By default Comsol 3.5a (that's the software version I have employed), in several mechanical modules allows to set displacements and not accelerations. I have solved such a problem in the following way: - import the data in tabular form (one column is the physical quantity, the other is time) in Comsol - call this function "data" (this will be, by default, a function of the type "f(x)") - setup a global equation where the function "data" is written as "data(t)", where t is the usual time variable. In this way the software "understands" that the independent variable is a time and not a space. I hope this helps.

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.