**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.

## Interpolation Function Help

Posted Jul 18, 2011, 9:33 AM EDT Modeling Tools, Parameters, Variables, & Functions Version 5.0 14 Replies

Erin Koksal

Good Morning,

I'm having trouble using COMSOL's interpolation function, and I was hoping someone might be able to help. I'm trying to load data from a tab-delimited text file. I've followed the instructions in the COMSOL user guide on interpolation functions, however I get the following error when I click "plot":

"Internal error in mesh initialization.

-Plot: previewplot1 (Surface)

-Function: int1"

Additionally, when I try to solve the model I get the following error message:

"-Feature: Compile Equations: Stationary (sol1/st1)

-Error: Internal error in mesh initialization."

When I disable the interpolation function, COMSOL successfully solves the model.

The input data used for the interpolation function was a velocity distribution exported from a previous solution surface. It has the following structure:

% x y z myfun1

0.005164328 0.094835672 0.2 0.098519135

0.015894103 0.087647192 0.2 0.511590803

0.015569986 0.095339275 0.2 0.22689919

0.006197193 0.083275657 0.2 0.312314232

0.005469283 0.016082383 0.2 0.2672031

0.004733427 0.004733427 0.2 0.081290304

0.012546053 0.01240331 0.2 0.43510989

0.015707096 0.004896326 0.2 0.232560416

0.027164381 0.094602393 0.2 0.368319369

etc.

A very simple flow model demonstrating the problem is attached, along with an excel version of the data I'm using. I'm a new COMSOL user, and any advice would be greatly appreciated.

Thank You!

I'm having trouble using COMSOL's interpolation function, and I was hoping someone might be able to help. I'm trying to load data from a tab-delimited text file. I've followed the instructions in the COMSOL user guide on interpolation functions, however I get the following error when I click "plot":

"Internal error in mesh initialization.

-Plot: previewplot1 (Surface)

-Function: int1"

Additionally, when I try to solve the model I get the following error message:

"-Feature: Compile Equations: Stationary (sol1/st1)

-Error: Internal error in mesh initialization."

When I disable the interpolation function, COMSOL successfully solves the model.

The input data used for the interpolation function was a velocity distribution exported from a previous solution surface. It has the following structure:

% x y z myfun1

0.005164328 0.094835672 0.2 0.098519135

0.015894103 0.087647192 0.2 0.511590803

0.015569986 0.095339275 0.2 0.22689919

0.006197193 0.083275657 0.2 0.312314232

0.005469283 0.016082383 0.2 0.2672031

0.004733427 0.004733427 0.2 0.081290304

0.012546053 0.01240331 0.2 0.43510989

0.015707096 0.004896326 0.2 0.232560416

0.027164381 0.094602393 0.2 0.368319369

etc.

A very simple flow model demonstrating the problem is attached, along with an excel version of the data I'm using. I'm a new COMSOL user, and any advice would be greatly appreciated.

Thank You!

Attachments:

14 Replies Last Post Feb 15, 2017, 1:19 AM EST

Yoann Many

Posted:
6 years ago
Jul 19, 2011, 3:32 AM EDT

Had the same issue with an imported data .txt file, and it has 2 parameters while yours seems to have three of them. The only thing I figured was to reduce the number of parameters to 1, and no more error messages.... But I guess in your case it's quite out of the question.....

sorry I can't help you

sorry I can't help you

Had the same issue with an imported data .txt file, and it has 2 parameters while yours seems to have three of them. The only thing I figured was to reduce the number of parameters to 1, and no more error messages.... But I guess in your case it's quite out of the question.....
sorry I can't help you

Lichun Wang

Posted:
5 years ago
Aug 14, 2012, 3:33 PM EDT

Me toooo! Once I used interpolation function with three arguments, it will pop out the error message. Hope someone expert will answer this question soon.

Me toooo! Once I used interpolation function with three arguments, it will pop out the error message. Hope someone expert will answer this question soon.

Nagi Elabbasi
Certified Consultant

Posted:
5 years ago
Aug 15, 2012, 2:37 PM EDT

One of your variables always has the same value of 0.2. It seems that this is not acceptable for COMSOL. If you change some numbers to say 0.3 it works. Alternatively you can remove that variable completely from the function.

Nagi Elabbasi

Veryst Engineering

Nagi Elabbasi

Veryst Engineering

One of your variables always has the same value of 0.2. It seems that this is not acceptable for COMSOL. If you change some numbers to say 0.3 it works. Alternatively you can remove that variable completely from the function.
Nagi Elabbasi
Veryst Engineering

Magnus Ringh
COMSOL Employee

Posted:
5 years ago
Aug 16, 2012, 8:38 AM EDT

Hi,

As Nagi explains above, an interpolation function of three arguments does not work well when one of them is a constant value (it is a degenerated case). Perhaps you want to treat this as function of two variables (arguments), neglecting the values in the third column. You can then import it without having to modify the data file but specifying, in the settings window for Interpolation, that there are 2 arguments, and, under Functions, that the position in the file for the function values is 2. That means that COMSOL treats columns 1 and 2 as the argument values, and the second of the following columns (that is, column 4) as the column with the associated function values. Column 3 is then not used.

In this particular case the data is in an Excel file, which the Interpolation function does not support in a general way, but you can save it as text file, which is a supported data format. Furthermore, the values in the file seem to use a decimal comma rather than a decimal point. Replacing commas with points in the text file it is possible to import it as described above and plot the interpolation function as a surface plot.

Best regards,

Magnus Ringh, COMSOL

As Nagi explains above, an interpolation function of three arguments does not work well when one of them is a constant value (it is a degenerated case). Perhaps you want to treat this as function of two variables (arguments), neglecting the values in the third column. You can then import it without having to modify the data file but specifying, in the settings window for Interpolation, that there are 2 arguments, and, under Functions, that the position in the file for the function values is 2. That means that COMSOL treats columns 1 and 2 as the argument values, and the second of the following columns (that is, column 4) as the column with the associated function values. Column 3 is then not used.

In this particular case the data is in an Excel file, which the Interpolation function does not support in a general way, but you can save it as text file, which is a supported data format. Furthermore, the values in the file seem to use a decimal comma rather than a decimal point. Replacing commas with points in the text file it is possible to import it as described above and plot the interpolation function as a surface plot.

Best regards,

Magnus Ringh, COMSOL

Hi,
As Nagi explains above, an interpolation function of three arguments does not work well when one of them is a constant value (it is a degenerated case). Perhaps you want to treat this as function of two variables (arguments), neglecting the values in the third column. You can then import it without having to modify the data file but specifying, in the settings window for Interpolation, that there are 2 arguments, and, under Functions, that the position in the file for the function values is 2. That means that COMSOL treats columns 1 and 2 as the argument values, and the second of the following columns (that is, column 4) as the column with the associated function values. Column 3 is then not used.
In this particular case the data is in an Excel file, which the Interpolation function does not support in a general way, but you can save it as text file, which is a supported data format. Furthermore, the values in the file seem to use a decimal comma rather than a decimal point. Replacing commas with points in the text file it is possible to import it as described above and plot the interpolation function as a surface plot.
Best regards,
Magnus Ringh, COMSOL

Xu Gong

Posted:
5 years ago
Oct 10, 2012, 7:02 PM EDT

Hi, Nagi:

I have a question for the interpolation function, can you help me? Thanks.

My function has two arguments p and e instead of coordinates x and y, and the form is:

G=f(p,e)

So, I create the spreadsheet as:

% p e G

1e6 0.5 2e6

2e6 0.6 3e6

etc...

But the COMSOL always assume to be coordinates as argument. How to fix this problem?

Thanks a lot.

Xu

I have a question for the interpolation function, can you help me? Thanks.

My function has two arguments p and e instead of coordinates x and y, and the form is:

G=f(p,e)

So, I create the spreadsheet as:

% p e G

1e6 0.5 2e6

2e6 0.6 3e6

etc...

But the COMSOL always assume to be coordinates as argument. How to fix this problem?

Thanks a lot.

Xu

Hi, Nagi:
I have a question for the interpolation function, can you help me? Thanks.
My function has two arguments p and e instead of coordinates x and y, and the form is:
G=f(p,e)
So, I create the spreadsheet as:
% p e G
1e6 0.5 2e6
2e6 0.6 3e6
etc...
But the COMSOL always assume to be coordinates as argument. How to fix this problem?
Thanks a lot.
Xu

Xu Gong

Posted:
5 years ago
Oct 10, 2012, 7:05 PM EDT

Hi, Magnus:

I have a question for the interpolation function, can you help me? Thanks.

My function has two arguments p and e instead of coordinates x and y, and the form is:

G=f(p,e)

So, I create the spreadsheet as:

% p e G

1e6 0.5 2e6

2e6 0.6 3e6

etc...

But the COMSOL always assume to be coordinates as argument. How to fix this problem?

Thanks a lot.

Xu

I have a question for the interpolation function, can you help me? Thanks.

My function has two arguments p and e instead of coordinates x and y, and the form is:

G=f(p,e)

So, I create the spreadsheet as:

% p e G

1e6 0.5 2e6

2e6 0.6 3e6

etc...

But the COMSOL always assume to be coordinates as argument. How to fix this problem?

Thanks a lot.

Xu

Hi, Magnus:
I have a question for the interpolation function, can you help me? Thanks.
My function has two arguments p and e instead of coordinates x and y, and the form is:
G=f(p,e)
So, I create the spreadsheet as:
% p e G
1e6 0.5 2e6
2e6 0.6 3e6
etc...
But the COMSOL always assume to be coordinates as argument. How to fix this problem?
Thanks a lot.
Xu

Jeff Hiller
COMSOL Employee

Posted:
5 years ago
Oct 11, 2012, 8:49 AM EDT

Hello Xu,

The Discussion Forum is primarily meant for customers to assist each other. To request support from COMSOL support personnel, please email support@comsol.com.

The Discussion Forum is primarily meant for customers to assist each other. To request support from COMSOL support personnel, please email support@comsol.com.

Hello Xu,
The Discussion Forum is primarily meant for customers to assist each other. To request support from COMSOL support personnel, please email support@comsol.com.

Francesco Travascio

Posted:
4 years ago
May 23, 2013, 2:43 PM EDT

Hi,

I have a quick question on the interpolation functions used a boundary conditions.

I am working on a 3D model with PDE weak form. I need to introduce a boundary condition for a weak contribution that is tabulated in a file. This is

f=f(t) meaning that the only input argument is the time.

I have a text file built in this way:

% t force

0 1

0.1 3

0.3 7

etc.,

When I introduce this function as boundary condition I receive the following error message:

Failed to evaluate variable Jacobian

- Variable: int1

-Geometry: 1

-Boundary: 4 8

-Feature: Time-Dependent Solver 1 (sol/t1)

-Error: Failed to evaluate variable Jacobian

can anybody help me?

thanks

I have a quick question on the interpolation functions used a boundary conditions.

I am working on a 3D model with PDE weak form. I need to introduce a boundary condition for a weak contribution that is tabulated in a file. This is

f=f(t) meaning that the only input argument is the time.

I have a text file built in this way:

% t force

0 1

0.1 3

0.3 7

etc.,

When I introduce this function as boundary condition I receive the following error message:

Failed to evaluate variable Jacobian

- Variable: int1

-Geometry: 1

-Boundary: 4 8

-Feature: Time-Dependent Solver 1 (sol/t1)

-Error: Failed to evaluate variable Jacobian

can anybody help me?

thanks

Hi,
I have a quick question on the interpolation functions used a boundary conditions.
I am working on a 3D model with PDE weak form. I need to introduce a boundary condition for a weak contribution that is tabulated in a file. This is
f=f(t) meaning that the only input argument is the time.
I have a text file built in this way:
% t force
0 1
0.1 3
0.3 7
etc.,
When I introduce this function as boundary condition I receive the following error message:
Failed to evaluate variable Jacobian
- Variable: int1
-Geometry: 1
-Boundary: 4 8
-Feature: Time-Dependent Solver 1 (sol/t1)
-Error: Failed to evaluate variable Jacobian
can anybody help me?
thanks

Sepideh Ramezani

Posted:
3 years ago
Feb 12, 2015, 5:26 AM EST

I have same problem, I want to impose an interpolation function and my data are like below:

% x y hh

90.603 53.779 -0.40248

84.429 93.007 -0.31846

92.494 133.702 -0.27818

110.658 216.016 -0.36048

127.878 296.939 -0.51878

But when I want to plot them, I am confronting with this error that: "Mesh interpolation failed".

Do you have any idea why I am getting this kind of error? Is it related to negative values of my function?

Is it sth happening in mesh?

Many thanks in advance for your help.

Sepideh

% x y hh

90.603 53.779 -0.40248

84.429 93.007 -0.31846

92.494 133.702 -0.27818

110.658 216.016 -0.36048

127.878 296.939 -0.51878

But when I want to plot them, I am confronting with this error that: "Mesh interpolation failed".

Do you have any idea why I am getting this kind of error? Is it related to negative values of my function?

Is it sth happening in mesh?

Many thanks in advance for your help.

Sepideh

I have same problem, I want to impose an interpolation function and my data are like below:
% x y hh
90.603 53.779 -0.40248
84.429 93.007 -0.31846
92.494 133.702 -0.27818
110.658 216.016 -0.36048
127.878 296.939 -0.51878
But when I want to plot them, I am confronting with this error that: "Mesh interpolation failed".
Do you have any idea why I am getting this kind of error? Is it related to negative values of my function?
Is it sth happening in mesh?
Many thanks in advance for your help.
Sepideh

Usharani Rath

Posted:
8 months ago
Feb 13, 2017, 1:30 AM EST

Hiii,

I am a beginner to COMSOL 5.2.

I am getting some problem while incorporating the interpolation function into my model.

The function is described below.

Pint(t) = 1, t<= 0.00007s,

decreases linearly to zero, 0.00007s<= t<= 0.00009s

0, t>= 0.00009s.

Can anyone help me out how to do the same.

thank you.

I am a beginner to COMSOL 5.2.

I am getting some problem while incorporating the interpolation function into my model.

The function is described below.

Pint(t) = 1, t<= 0.00007s,

decreases linearly to zero, 0.00007s<= t<= 0.00009s

0, t>= 0.00009s.

Can anyone help me out how to do the same.

thank you.

Hiii,
I am a beginner to COMSOL 5.2.
I am getting some problem while incorporating the interpolation function into my model.
The function is described below.
Pint(t) = 1, t

Jeff Hiller
COMSOL Employee

Posted:
8 months ago
Feb 13, 2017, 1:53 PM EST

Usharani,

Can you be more specific about the problem you're encountering? It should be a straightforward use of interpolation functions.

Best,

Jeff

Can you be more specific about the problem you're encountering? It should be a straightforward use of interpolation functions.

Best,

Jeff

Usharani,
Can you be more specific about the problem you're encountering? It should be a straightforward use of interpolation functions.
Best,
Jeff

Usharani Rath

Posted:
8 months ago
Feb 14, 2017, 1:54 AM EST

Hiii Jeff,

The issue is when I am plotting the interpolation function by putting the values of t and F(t) in the local table, the plot is like a step function only. It does not take into account the values provided in the local table.

Regards,

Usha

The issue is when I am plotting the interpolation function by putting the values of t and F(t) in the local table, the plot is like a step function only. It does not take into account the values provided in the local table.

Regards,

Usha

Hiii Jeff,
The issue is when I am plotting the interpolation function by putting the values of t and F(t) in the local table, the plot is like a step function only. It does not take into account the values provided in the local table.
Regards,
Usha

Gunnar Andersson
COMSOL Employee

Posted:
8 months ago
Feb 14, 2017, 3:04 AM EST

The issue is when I am plotting the interpolation function by putting the values of t and F(t) in the local table, the plot is like a step function only. It does not take into account the values provided in the local table.

Preview plots of functions by default use 10000 points (in the latest version, 5.2a), so they aren't guaranteed to capture dynamics on all scales. Note that this also holds for the solver: Make sure to set up the time list to capture the dynamics, or else the solver might step past it.

[QUOTE]
The issue is when I am plotting the interpolation function by putting the values of t and F(t) in the local table, the plot is like a step function only. It does not take into account the values provided in the local table.
[/QUOTE]
Preview plots of functions by default use 10000 points (in the latest version, 5.2a), so they aren't guaranteed to capture dynamics on all scales. Note that this also holds for the solver: Make sure to set up the time list to capture the dynamics, or else the solver might step past it.

Usharani Rath

Posted:
8 months ago
Feb 15, 2017, 1:19 AM EST

Thank you Mr. Andersson.

Thank you Mr. Andersson.

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.

## Suggested Content

- BLOG Using Radial Basis Functions for Surface Interpolation
- FORUM non-uniform interpolation function
- KNOWLEDGE BASE GLIBCXX_3.4.9 not found error message when calling an external MATLAB function
- BLOG Efficiently Assign Materials in Your COMSOL MultiphysicsÂ® Model
- KNOWLEDGE BASE Undefined function call