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.

File input trouble (Unknown Variable)

Please login with a confirmed email address before reporting spam

Hello, in my simulation, I am trying to use some telemetry data formatted into an Excel spreadsheet. The first column has time data and the second has corresponding Wattage from a heater. Under Global Definitions, I made an Interpolation Function and imported the data with these settings:
Function name: Q_t
Position in File: 1
Interpolation: Nearest Neighbor
Extrapolation: Constant

Plotting this results in the same plot I'd see in Excel or MATLAB, so I'm assuming COMSOL recognizes the data. However, when I try to use "Q_t" later, it gives me a warning and "Unknown Variable Q_t." To be thorough, I have Heat Transfer > Heat Flux, where total heat flux is defined by Q_t

8 Replies Last Post 28.01.2016, 09:20 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: 9 years ago 27.01.2016, 02:01 GMT-5
Hi

COMSOL has thousands of internal variables, if you use a few physics modules so often its quite simple to hit an already used name, and sometimes you may get trouble and strange results, without specially any warnings, because COMSOL allows you to change internal variables, therefore it could be correct that you change some internal variable, COMSOL cannot tell.

My way around is to :
a) use names with some length and/or some special termination or prefix as"my_var_"
b) check the names by defining a dummy Parameter and equate it to the name, if some values or units pop up, there is a good chance that the variable is already defined, but this last trick is not sufficient, it will only work with active variables once the model is set up and you have at least run an "get initial conditions" ideally solved the model once.
c) do the same (or ignore b and directly go to c) in the Definitions Variable, define a dummy variable and equate it to the name I want to use, again if some units pop up there is a good chance that its already defined as an internal variable. If the variable is flagged red probably its a genuine name at least until you load a new physics with more variables.
d) one must also refer to the scope of the variables, dependent variables are defined "globally" such as (u,v,w) but most physics variable are tagged with the specific physics prefix i.e. such as "solid.freq" : internal "solid" physics - eigenfrequency variable.

To get a view of the many variables under the hood, activate the equation view and study the equations therein (set in the preferences)

--
Good luck
Ivar
Hi COMSOL has thousands of internal variables, if you use a few physics modules so often its quite simple to hit an already used name, and sometimes you may get trouble and strange results, without specially any warnings, because COMSOL allows you to change internal variables, therefore it could be correct that you change some internal variable, COMSOL cannot tell. My way around is to : a) use names with some length and/or some special termination or prefix as"my_var_" b) check the names by defining a dummy Parameter and equate it to the name, if some values or units pop up, there is a good chance that the variable is already defined, but this last trick is not sufficient, it will only work with active variables once the model is set up and you have at least run an "get initial conditions" ideally solved the model once. c) do the same (or ignore b and directly go to c) in the Definitions Variable, define a dummy variable and equate it to the name I want to use, again if some units pop up there is a good chance that its already defined as an internal variable. If the variable is flagged red probably its a genuine name at least until you load a new physics with more variables. d) one must also refer to the scope of the variables, dependent variables are defined "globally" such as (u,v,w) but most physics variable are tagged with the specific physics prefix i.e. such as "solid.freq" : internal "solid" physics - eigenfrequency variable. To get a view of the many variables under the hood, activate the equation view and study the equations therein (set in the preferences) -- Good luck Ivar

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27.01.2016, 04:17 GMT-5
Hi,

I think the problem might be that you call the interpolation function without arguments. You should call it using something like

Q_t(x,y)

depending on the number of arguments of the function and the geometry dimension.

Best regards,
Magnus Ringh, COMSOL
Hi, I think the problem might be that you call the interpolation function without arguments. You should call it using something like Q_t(x,y) depending on the number of arguments of the function and the geometry dimension. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27.01.2016, 09:30 GMT-5
Hello, thank you both for replies. I tried renaming the variable to something specific (Heater41) as Ivar suggested. Still no luck. I then tried Heater41(t), which also did not work. Could it be something with the input file itself?

The first 10 rows of the input file looks like this:
0.00, 0.00
3.02, 0.00
6.05, 0.00
9.07, 0.00
12.01, 0.00
15.03, 0.00
18.06, 0.00
21.08, 0.00
24.02, 0.00
27.04, 0.00
and there are about 200000 more rows (mostly zeros- this heater doesn't come on often). Or could it be that the time step isn't constant? I can't imagine it's the file itself. Like I said, COMSOL does recognize the data when I plot it.
Hello, thank you both for replies. I tried renaming the variable to something specific (Heater41) as Ivar suggested. Still no luck. I then tried Heater41(t), which also did not work. Could it be something with the input file itself? The first 10 rows of the input file looks like this: 0.00, 0.00 3.02, 0.00 6.05, 0.00 9.07, 0.00 12.01, 0.00 15.03, 0.00 18.06, 0.00 21.08, 0.00 24.02, 0.00 27.04, 0.00 and there are about 200000 more rows (mostly zeros- this heater doesn't come on often). Or could it be that the time step isn't constant? I can't imagine it's the file itself. Like I said, COMSOL does recognize the data when I plot it.

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27.01.2016, 09:52 GMT-5
Hi Ryan,

That should work. Could you post a simple example file (MPH-file) and the input file? Otherwise, it's hard to say what the problem is.

Best regards,
Magnus Ringh, COMSOL
Hi Ryan, That should work. Could you post a simple example file (MPH-file) and the input file? Otherwise, it's hard to say what the problem is. Best regards, Magnus Ringh, COMSOL

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: 9 years ago 27.01.2016, 15:26 GMT-5
Hi

could this be the same issue reported some months ago (22 oct 2015) also on the Forum, about COMSOL's way of plot resampling and loss of visual data (although if I remember all data was used internally) ?

Because there was quite some differences in peak values and visual read out of plotted values for a long input file
see
www.comsol.eu/community/forums/general/thread/93111

--
Good luck
Ivar
Hi could this be the same issue reported some months ago (22 oct 2015) also on the Forum, about COMSOL's way of plot resampling and loss of visual data (although if I remember all data was used internally) ? Because there was quite some differences in peak values and visual read out of plotted values for a long input file see https://www.comsol.eu/community/forums/general/thread/93111 -- Good luck Ivar

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 28.01.2016, 04:07 GMT-5
Hi Ryan,

Interesting model! I tested it in COMSOL Multiphysics version 5.2 (our current version), and it runs without errors. I can see now that you tagged this posting with version 4.3b. A lot has happened since that version, so I strongly recommend that you update to the latest version.

However, I also tested this model in version 4.3b, and it worked for me in that version, too.

Best regards,
Magnus Ringh, COMSOL
Hi Ryan, Interesting model! I tested it in COMSOL Multiphysics version 5.2 (our current version), and it runs without errors. I can see now that you tagged this posting with version 4.3b. A lot has happened since that version, so I strongly recommend that you update to the latest version. However, I also tested this model in version 4.3b, and it worked for me in that version, too. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 28.01.2016, 08:54 GMT-5

Hi

could this be the same issue reported some months ago (22 oct 2015) also on the Forum, about COMSOL's way of plot resampling and loss of visual data (although if I remember all data was used internally) ?

Because there was quite some differences in peak values and visual read out of plotted values for a long input file
see
www.comsol.eu/community/forums/general/thread/93111

--
Good luck
Ivar


With this issue, this user was able to import the spreadsheet and use it, but she just had different results than what she expected. I am able to import the spreadsheet, but I am unable to call the function later. It's close though. It does sound like I have the same format in my spreadsheet, with one column of time, and one column of data.


Hi Ryan,

Interesting model! I tested it in COMSOL Multiphysics version 5.2 (our current version), and it runs without errors. I can see now that you tagged this posting with version 4.3b. A lot has happened since that version, so I strongly recommend that you update to the latest version.

However, I also tested this model in version 4.3b, and it worked for me in that version, too.

Best regards,
Magnus Ringh, COMSOL


Interesting. Can you walk me through what you did, if you changed anything from the file I gave you? I feel like I'm missing one tiny thing.
[QUOTE] Hi could this be the same issue reported some months ago (22 oct 2015) also on the Forum, about COMSOL's way of plot resampling and loss of visual data (although if I remember all data was used internally) ? Because there was quite some differences in peak values and visual read out of plotted values for a long input file see https://www.comsol.eu/community/forums/general/thread/93111 -- Good luck Ivar [/QUOTE] With this issue, this user was able to import the spreadsheet and use it, but she just had different results than what she expected. I am able to import the spreadsheet, but I am unable to call the function later. It's close though. It does sound like I have the same format in my spreadsheet, with one column of time, and one column of data. [QUOTE] Hi Ryan, Interesting model! I tested it in COMSOL Multiphysics version 5.2 (our current version), and it runs without errors. I can see now that you tagged this posting with version 4.3b. A lot has happened since that version, so I strongly recommend that you update to the latest version. However, I also tested this model in version 4.3b, and it worked for me in that version, too. Best regards, Magnus Ringh, COMSOL [/QUOTE] Interesting. Can you walk me through what you did, if you changed anything from the file I gave you? I feel like I'm missing one tiny thing.

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 28.01.2016, 09:20 GMT-5
Hi Ryan,

I opened the MPH-file and re-solved. I also discarded the interpolation data and reimported it from the data you sent (saved from the M-file as a plain text file) and re-solved again. I did not change any other settings. If you still cannot get it to work, I recommend that you contact your local COMSOL office for technical support.

Best regards,
Magnus Ringh, COMSOL
Hi Ryan, I opened the MPH-file and re-solved. I also discarded the interpolation data and reimported it from the data you sent (saved from the M-file as a plain text file) and re-solved again. I did not change any other settings. If you still cannot get it to work, I recommend that you contact your local COMSOL office for technical support. Best regards, Magnus Ringh, COMSOL

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.