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.

Importing time dependent Boundary Condition

Please login with a confirmed email address before reporting spam

Hello to everyone,

I am new to the use of COMSOL, and i am wondering if it is possible to import a time dependent BC from a .txt file.

Practically, I have to set up a time dependent mechanical model in which my geometry has a time dependent BC coming from the results of a CFD simulation with another software.

The .txt file I have to import within the comsol model is made as follows:

x y z A(t1) A(t2) A(t3)......A(tn)
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .

I have tried to use an interpolation function in which the "position in file" is a time variable, but comsol returns me the message error "the file position must be a positive integer".

Can anyone suggest me how to solve the problem? Can COMSOL handle this kind of situation?

Thank you all.

7 Replies Last Post Jun 9, 2015, 4:16 a.m. EDT
COMSOL Moderator

Hello Danilo D'Agostino

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 9 years ago Apr 28, 2015, 10:06 a.m. EDT
Hi Danilo,

I encountered a quite similar problem recently. I want to import time and space dependent boundary conditions from a file too. But it seems that COMSOL cannot handle the time dimension. I m wondering if you have found a solution or find a way to get around it.

Thx
Hi Danilo, I encountered a quite similar problem recently. I want to import time and space dependent boundary conditions from a file too. But it seems that COMSOL cannot handle the time dimension. I m wondering if you have found a solution or find a way to get around it. Thx

Frank van Gool COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Apr 28, 2015, 10:59 a.m. EDT
Dear Danilo,

There is the option of using an interpolation function. You will need to rewrite your table to x, y, z, t.
Note that COMSOL only supports 3 arguments (as it plots the function on a 3D grid), and thus you will need to remove 1 spatial coordinate. As you talk about a boundary condition, you might be able to rewrite to surface parameters.

Another alternative would be to rewrite the table to an analytical function (depending on the data this can be hard), or to use the livelink with MATLAB, or use an external function.

Best regards,
Frank
Dear Danilo, There is the option of using an interpolation function. You will need to rewrite your table to x, y, z, t. Note that COMSOL only supports 3 arguments (as it plots the function on a 3D grid), and thus you will need to remove 1 spatial coordinate. As you talk about a boundary condition, you might be able to rewrite to surface parameters. Another alternative would be to rewrite the table to an analytical function (depending on the data this can be hard), or to use the livelink with MATLAB, or use an external function. Best regards, Frank

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Apr 28, 2015, 5:30 p.m. EDT

Dear Danilo,

There is the option of using an interpolation function. You will need to rewrite your table to x, y, z, t.
Note that COMSOL only supports 3 arguments (as it plots the function on a 3D grid), and thus you will need to remove 1 spatial coordinate. As you talk about a boundary condition, you might be able to rewrite to surface parameters.

Another alternative would be to rewrite the table to an analytical function (depending on the data this can be hard), or to use the livelink with MATLAB, or use an external function.

Best regards,
Frank


Hi Frank,

Basically I want to import data from the file to define boundary conditions.

I tried as what you suggested: I rewrite the table. The arguments now are x, y and t (because my model is 2D and the interpolation function I'm trying to import is time dependent). But when I click on the button "Import", an error message pops up saying "Internal error in mesh initialization".

So I'm thinking about splitting the file into as many functions as the time step number. Then we get:
f(x,y,t=0)
f(x,y,t=1)
f(x,y,t=2)
......
f(x,y,t=n) , where n = the number of time steps

But a new problem appears very soon: if I want to use these data to set time and space dependant boundary conditions, I still need to merge these functions (f(x,y,t=1), f(x,y,t=2),...) to get a time and space dependant function f(x,y,t). But I cannot find a way to do this in COMSOL . I've been stuck here for a week : (

Can you give me some suggestions?
Many thanks ;)
[QUOTE] Dear Danilo, There is the option of using an interpolation function. You will need to rewrite your table to x, y, z, t. Note that COMSOL only supports 3 arguments (as it plots the function on a 3D grid), and thus you will need to remove 1 spatial coordinate. As you talk about a boundary condition, you might be able to rewrite to surface parameters. Another alternative would be to rewrite the table to an analytical function (depending on the data this can be hard), or to use the livelink with MATLAB, or use an external function. Best regards, Frank [/QUOTE] Hi Frank, Basically I want to import data from the file to define boundary conditions. I tried as what you suggested: I rewrite the table. The arguments now are x, y and t (because my model is 2D and the interpolation function I'm trying to import is time dependent). But when I click on the button "Import", an error message pops up saying "Internal error in mesh initialization". So I'm thinking about splitting the file into as many functions as the time step number. Then we get: f(x,y,t=0) f(x,y,t=1) f(x,y,t=2) ...... f(x,y,t=n) , where n = the number of time steps But a new problem appears very soon: if I want to use these data to set time and space dependant boundary conditions, I still need to merge these functions (f(x,y,t=1), f(x,y,t=2),...) to get a time and space dependant function f(x,y,t). But I cannot find a way to do this in COMSOL . I've been stuck here for a week : ( Can you give me some suggestions? Many thanks ;)

Frank van Gool COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Apr 29, 2015, 10:46 a.m. EDT
Dear Yuankang,

attached an example of a 3D function, that is, x, y, t.
You can import this as an interpolation function under your component definitions.

If it still fails, you can upload your files to the forum so someone can help you out with it.

Best regards,
Frank
Dear Yuankang, attached an example of a 3D function, that is, x, y, t. You can import this as an interpolation function under your component definitions. If it still fails, you can upload your files to the forum so someone can help you out with it. Best regards, Frank


Please login with a confirmed email address before reporting spam

Posted: 9 years ago Apr 29, 2015, 5:30 p.m. EDT
Dear Frank,

My file looks very like yours. I have no idea why the error occurs when I import my data. It seems the only difference is that my file is much larger.
I attached my file here. if you have time to take a look at it, I ll be very grateful :)

YK
Dear Frank, My file looks very like yours. I have no idea why the error occurs when I import my data. It seems the only difference is that my file is much larger. I attached my file here. if you have time to take a look at it, I ll be very grateful :) YK


Frank van Gool COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago Apr 30, 2015, 3:59 a.m. EDT
Dear Yuankang,

In your file the values of of the x and y axis are in the order of 100's. Your time axis is in the 1e-9 scale. This causes an issue here because they are very different (remember that COMSOL maps the values to a grid).

What you can do is multiply your 3rd column with 1e9, so that the values are in the same order (not needed for the AccX).
You can then use the units field at the bottom to indicate that the time is in ns.

Best regards,
Frank
Dear Yuankang, In your file the values of of the x and y axis are in the order of 100's. Your time axis is in the 1e-9 scale. This causes an issue here because they are very different (remember that COMSOL maps the values to a grid). What you can do is multiply your 3rd column with 1e9, so that the values are in the same order (not needed for the AccX). You can then use the units field at the bottom to indicate that the time is in ns. Best regards, Frank


Please login with a confirmed email address before reporting spam

Posted: 9 years ago Jun 9, 2015, 4:16 a.m. EDT
Hi everyone,

I have the exact problem as mentioned above,
I have to upload boundary conditions to my 3d model and so have the data with 4 arguments i.e x,y,z and t (time),
I have understood and tried to upload it with three arguments x y and t but i need it for all the fours as is required for my model,
Could anyone please let me know if there is a way to do this (I believe the interpolation function is just for three arguments)??
if someone has accomplished this in some way, please share ur experience,
I would really appreciate your help,


Best Regards,
Safi Ur Rehman
Hi everyone, I have the exact problem as mentioned above, I have to upload boundary conditions to my 3d model and so have the data with 4 arguments i.e x,y,z and t (time), I have understood and tried to upload it with three arguments x y and t but i need it for all the fours as is required for my model, Could anyone please let me know if there is a way to do this (I believe the interpolation function is just for three arguments)?? if someone has accomplished this in some way, please share ur experience, I would really appreciate your help, Best Regards, Safi Ur Rehman

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.