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 insert a txt file as a source term in pde

Please login with a confirmed email address before reporting spam

Is there anyone who know how to do it? Here is what I have done

Model Builder-->Global Definitions-->Functions-->Interpolations,
chose file option, and import the txt file with spreadsheet format.
Then the plot shows the format of txt file is correct.
I use the Coefficient Form PDE to solve my problem. In the PDE,
I need the f(source term) to be replaced by that interpolation of txt
file I have imported. But it dosen't work :(

Thanks a lot!

1 Reply Last Post 18 août 2011, 15:02 UTC−4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18 août 2011, 15:02 UTC−4
I have figured out how to interpolate a txt file as a source term in PDE. Firstly I need to go to the globla of local definition node, then Functions-->Interpolation, source data-->file, import the file you want, select the correct data format according to my txt file(you can see the detailed information of data format in the help documents of Comsol) and give it a name int. Secondly I created a variable under definition node and give a name as same as int in the expression column and named this variable source. Thirdly, go to the coefficient pde form and replaced the term f with source. Then, it works.

But here comes another problem. I got abvious different temperature field with different txt file, although they are the same source data file. The only difference between these files is the density of data in the same domain. For example, in a cubic with side 1cm, the temperature field density of 50*50*50 heat source data density is very lower than that of 20*20*20 data density. The total amount of heat in this cubic is fixed. I know this is because the interpolation and extrapolation algorithm in comsol doesn't match what I desired. There are four options for interpolation and extrapolation respectively. I read them and tried them. None of the combination works. The correct interpolation I need is to accumulate the data on the structural grids in txt file to the mesh elements if these grids are within an elements. It seems that Comsol doesn't work it automatically.

Maybe I need to interpolate them by myself with matlab and then use matlab functions incomsol. Does anyone has any idea about how to do that? By the way, the version is Comsol4.1.
Thank you
I have figured out how to interpolate a txt file as a source term in PDE. Firstly I need to go to the globla of local definition node, then Functions-->Interpolation, source data-->file, import the file you want, select the correct data format according to my txt file(you can see the detailed information of data format in the help documents of Comsol) and give it a name int. Secondly I created a variable under definition node and give a name as same as int in the expression column and named this variable source. Thirdly, go to the coefficient pde form and replaced the term f with source. Then, it works. But here comes another problem. I got abvious different temperature field with different txt file, although they are the same source data file. The only difference between these files is the density of data in the same domain. For example, in a cubic with side 1cm, the temperature field density of 50*50*50 heat source data density is very lower than that of 20*20*20 data density. The total amount of heat in this cubic is fixed. I know this is because the interpolation and extrapolation algorithm in comsol doesn't match what I desired. There are four options for interpolation and extrapolation respectively. I read them and tried them. None of the combination works. The correct interpolation I need is to accumulate the data on the structural grids in txt file to the mesh elements if these grids are within an elements. It seems that Comsol doesn't work it automatically. Maybe I need to interpolate them by myself with matlab and then use matlab functions incomsol. Does anyone has any idea about how to do that? By the way, the version is Comsol4.1. Thank you

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.