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.

Function of two variables

Please login with a confirmed email address before reporting spam

Hello,

I am using COMSOL Multiphysics 3.5a to simulate electrical conduction in silicon under high electric fields / temperatures. I am using the physics DC conductive media and Heat transfer by conduction. I also have COMSOL 4.0a but I am using 3.5a because it is familiar to me, so some help in either version would be appreciated. I am currently using a model for conductivity which only depends on temperature, and I would like to make this a function of two variables - temperature and electric field. However, I am have a difficult time setting up this function of two variables.

When I go to Options > Functions to create a new function from a Table, there are only two columns x and f(x), and I obviously need 3 columns x, y, and f(x,y). When I imported a 3 column text file as a function, it says the data type is Unstructured with Dimension 2D. The data is a .txt file with 3 columns of numbers separated by tabs, with no column headers just data. It does not let me view the data numerically or graphically. I have no idea how is it interpolating between the points, what the data actually looks like in COMSOL, which columns are being designated to what, etc.

I do not have an explicit function for conductivity as a function of temperature and electric field, but rather a set points of experimental data for a range of electric field and temperature values. It would be nice to enter these points in COMSOL and have it do some cubic interpolation of the 3-D plane (x = temperature, y = electric field, z = conductivity), just like how it interpolates a function of one variable. I could also do this in MATLAB though, and just import a large 3-column array of data, however I can't figure this out either.

I would very much appreciate some help in getting this function of two variables running for my simulations.
Thanks,
Adam
University of Connecticut

9 Replies Last Post Apr 23, 2012, 2:58 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 22, 2010, 10:29 a.m. EST
There must be a way to implement a function of two variables in COMSOL . . .

Has anyone done this before? Is there anyone who can help me?
There must be a way to implement a function of two variables in COMSOL . . . Has anyone done this before? Is there anyone who can help me?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 22, 2010, 10:43 a.m. EST
I don't use the MatLab Link, but at least this would be the way to solve this problem. Working with COMSOL under MatLab. Then you should be able to use the buitl-in interpolation funtions of MatLab.
I don't use the MatLab Link, but at least this would be the way to solve this problem. Working with COMSOL under MatLab. Then you should be able to use the buitl-in interpolation funtions of MatLab.

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 Nov 22, 2010, 2:50 p.m. EST
Hi

have you read the chapter on "Analytical Functions" in the user "guide.pdf" of the 3.5a doc ?

--
Good luck
Ivar
Hi have you read the chapter on "Analytical Functions" in the user "guide.pdf" of the 3.5a doc ? -- Good luck Ivar

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 23, 2010, 7:28 a.m. EST
Hi,

It is possible to define a function of two variables using an interpolation function defined in a text file using the spreadsheet data format: the first column contains the values for the first input argument, the second column contains the values for the seond input argument, and the third column contains the function's value. Each row then contains a set of two input arguments and the corresponding function value:

x1 y1 f(x1,y1)
x2 y2 f(x2,y2)
...

The Spreadsheet data format is documented in the File Formats chapter of the COMSOL Multiphysics Reference Guide for version 4. I recommend using version 4, where you can get a preview plot by clicking the Plot button. COMSOL Multiphysics then shows a surface plot of the function in the Graphics window so that you can see the effects of the various interpolation and extrapolation options before using the function in the model.

Best regards,
Magnus Ringh, COMSOL
Hi, It is possible to define a function of two variables using an interpolation function defined in a text file using the spreadsheet data format: the first column contains the values for the first input argument, the second column contains the values for the seond input argument, and the third column contains the function's value. Each row then contains a set of two input arguments and the corresponding function value: x1 y1 f(x1,y1) x2 y2 f(x2,y2) ... The Spreadsheet data format is documented in the File Formats chapter of the COMSOL Multiphysics Reference Guide for version 4. I recommend using version 4, where you can get a preview plot by clicking the Plot button. COMSOL Multiphysics then shows a surface plot of the function in the Graphics window so that you can see the effects of the various interpolation and extrapolation options before using the function in the model. Best regards, Magnus Ringh, COMSOL

Prithivirajan Veerappan

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 28, 2011, 3:00 p.m. EDT
x y f(x,y)......


i have given in the above format and its showing the following error

Error: 6080
Interpolation grid axis values must be sorted in ascending order in each dimension

Exception:
com.femlab.jni.FlNativeException: Non monotonous interpolation grid
Messages:
Non monotonous interpolation grid

Stack trace:
at interpolator.cpp, row 408, ()
at com.femlab.xmesh.Xmesh.addElems(Native Method)
at com.femlab.xmesh.Xmesh.addElems(Unknown Source)
at com.femlab.commands.MeshExtendCommand.c(Unknown Source)
at com.femlab.commands.MeshExtendCommand.r(Unknown Source)
at com.femlab.commands.MeshExtendCommand.evalOnServer(Unknown Source)
at com.femlab.commands.FlCommand.runServerCode(Unknown Source)
at com.femlab.server.ServerProxy.eval(Unknown Source)
at com.femlab.commands.FlCommand.a(Unknown Source)
at com.femlab.commands.FlCommand.eval(Unknown Source)
at com.femlab.commands.a.a(Unknown Source)
at com.femlab.util.CoreUtil.meshExtend(Unknown Source)
at com.femlab.api.client.Solver.solve(Unknown Source)
at com.femlab.api.client.SolveModel.a(Unknown Source)
at com.femlab.api.client.SolveModel.a(Unknown Source)
at com.femlab.api.client.x.a(Unknown Source)
at com.femlab.gui.FlProgressThread.run(Unknown Source)
at com.femlab.util.j.run(Unknown Source)
at com.femlab.util.ae.run(Unknown Source)
x y f(x,y)...... i have given in the above format and its showing the following error Error: 6080 Interpolation grid axis values must be sorted in ascending order in each dimension Exception: com.femlab.jni.FlNativeException: Non monotonous interpolation grid Messages: Non monotonous interpolation grid Stack trace: at interpolator.cpp, row 408, () at com.femlab.xmesh.Xmesh.addElems(Native Method) at com.femlab.xmesh.Xmesh.addElems(Unknown Source) at com.femlab.commands.MeshExtendCommand.c(Unknown Source) at com.femlab.commands.MeshExtendCommand.r(Unknown Source) at com.femlab.commands.MeshExtendCommand.evalOnServer(Unknown Source) at com.femlab.commands.FlCommand.runServerCode(Unknown Source) at com.femlab.server.ServerProxy.eval(Unknown Source) at com.femlab.commands.FlCommand.a(Unknown Source) at com.femlab.commands.FlCommand.eval(Unknown Source) at com.femlab.commands.a.a(Unknown Source) at com.femlab.util.CoreUtil.meshExtend(Unknown Source) at com.femlab.api.client.Solver.solve(Unknown Source) at com.femlab.api.client.SolveModel.a(Unknown Source) at com.femlab.api.client.SolveModel.a(Unknown Source) at com.femlab.api.client.x.a(Unknown Source) at com.femlab.gui.FlProgressThread.run(Unknown Source) at com.femlab.util.j.run(Unknown Source) at com.femlab.util.ae.run(Unknown Source)

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 28, 2011, 3:15 p.m. EDT
Hi

the grid data must be ordered in increasing order if I remember right X first, Y after then f(x,y) pls check as as usual, I could be 50% off.

Try to save a data txxt file i.e. one from a material or a postprocessing plot and compare (2 dimensional)

--
Good luck
Ivar
Hi the grid data must be ordered in increasing order if I remember right X first, Y after then f(x,y) pls check as as usual, I could be 50% off. Try to save a data txxt file i.e. one from a material or a postprocessing plot and compare (2 dimensional) -- Good luck Ivar

Prithivirajan Veerappan

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 28, 2011, 3:42 p.m. EDT
i have given it like

x y f...with x in ascending order and now the error is


Error: 9048
Format of data file is not correct.
It should contain grid and data values separated by lines starting with %


Exception:
com.femlab.util.FlException: Format of data file is not correct
Messages:
Format of data file is not correct

Stack trace:
at com.femlab.api.server.InterpElem.a(Unknown Source)
at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source)
at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source)
at com.femlab.api.server.XFem.toElemSyntax(Unknown Source)
at com.femlab.commands.MeshExtendCommand.<init>(Unknown Source)
at com.femlab.util.CoreUtil.meshExtend(Unknown Source)
at com.femlab.api.client.Solver.solve(Unknown Source)
at com.femlab.api.client.SolveModel.a(Unknown Source)
at com.femlab.api.client.SolveModel.a(Unknown Source)
at com.femlab.api.client.x.a(Unknown Source)
at com.femlab.gui.FlProgressThread.run(Unknown Source)
at com.femlab.util.j.run(Unknown Source)
at com.femlab.util.ae.run(Unknown Source)
i have given it like x y f...with x in ascending order and now the error is Error: 9048 Format of data file is not correct. It should contain grid and data values separated by lines starting with % Exception: com.femlab.util.FlException: Format of data file is not correct Messages: Format of data file is not correct Stack trace: at com.femlab.api.server.InterpElem.a(Unknown Source) at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source) at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source) at com.femlab.api.server.XFem.toElemSyntax(Unknown Source) at com.femlab.commands.MeshExtendCommand.(Unknown Source) at com.femlab.util.CoreUtil.meshExtend(Unknown Source) at com.femlab.api.client.Solver.solve(Unknown Source) at com.femlab.api.client.SolveModel.a(Unknown Source) at com.femlab.api.client.SolveModel.a(Unknown Source) at com.femlab.api.client.x.a(Unknown Source) at com.femlab.gui.FlProgressThread.run(Unknown Source) at com.femlab.util.j.run(Unknown Source) at com.femlab.util.ae.run(Unknown Source)

Prithivirajan Veerappan

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 28, 2011, 3:43 p.m. EDT
i have given it like

x y f...with x in ascending order and now the error is


Error: 9048
Format of data file is not correct.
It should contain grid and data values separated by lines starting with %


Exception:
com.femlab.util.FlException: Format of data file is not correct
Messages:
Format of data file is not correct

Stack trace:
at com.femlab.api.server.InterpElem.a(Unknown Source)
at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source)
at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source)
at com.femlab.api.server.XFem.toElemSyntax(Unknown Source)
at com.femlab.commands.MeshExtendCommand.<init>(Unknown Source)
at com.femlab.util.CoreUtil.meshExtend(Unknown Source)
at com.femlab.api.client.Solver.solve(Unknown Source)
at com.femlab.api.client.SolveModel.a(Unknown Source)
at com.femlab.api.client.SolveModel.a(Unknown Source)
at com.femlab.api.client.x.a(Unknown Source)
at com.femlab.gui.FlProgressThread.run(Unknown Source)
at com.femlab.util.j.run(Unknown Source)
at com.femlab.util.ae.run(Unknown Source)
i have given it like x y f...with x in ascending order and now the error is Error: 9048 Format of data file is not correct. It should contain grid and data values separated by lines starting with % Exception: com.femlab.util.FlException: Format of data file is not correct Messages: Format of data file is not correct Stack trace: at com.femlab.api.server.InterpElem.a(Unknown Source) at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source) at com.femlab.api.server.InterpElem.toElemSyntaxes(Unknown Source) at com.femlab.api.server.XFem.toElemSyntax(Unknown Source) at com.femlab.commands.MeshExtendCommand.(Unknown Source) at com.femlab.util.CoreUtil.meshExtend(Unknown Source) at com.femlab.api.client.Solver.solve(Unknown Source) at com.femlab.api.client.SolveModel.a(Unknown Source) at com.femlab.api.client.SolveModel.a(Unknown Source) at com.femlab.api.client.x.a(Unknown Source) at com.femlab.gui.FlProgressThread.run(Unknown Source) at com.femlab.util.j.run(Unknown Source) at com.femlab.util.ae.run(Unknown Source)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 23, 2012, 2:58 a.m. EDT
I had a similar problem trying to input values from a Cristy and Johnson table.

Turned out my problem(I got the first error message you got) was that there was one variable with a repeated value but different function value, ie

x1 f(x1)
1 5
1 6

You might want to go through your table in matlab or excel and just check you don't have any repeated values freaking the fit program out. You may have x in ascending order but if there's a repeated y value it might screw it up.

Did you sort this out? I need to do the same thing with 2 interpolations over a phase change.
I had a similar problem trying to input values from a Cristy and Johnson table. Turned out my problem(I got the first error message you got) was that there was one variable with a repeated value but different function value, ie x1 f(x1) 1 5 1 6 You might want to go through your table in matlab or excel and just check you don't have any repeated values freaking the fit program out. You may have x in ascending order but if there's a repeated y value it might screw it up. Did you sort this out? I need to do the same thing with 2 interpolations over a phase change.

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.