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 understand the code of comsol in matlab editor.

Please login with a confirmed email address before reporting spam

how can i understand the code of programme that is developed with the help of COMSOL and saved as m file and now it is obtained in COMSOL MATLAB editor. how to get to know the curve it shows belongs to which time level, how can we obtain the cuerves for each time level in the same graph window.

i m solving diffusion equation non-dimensional with no parameter in it. on 0,1 domain with Sinpix as initial condition.

31 Replies Last Post 23.11.2012, 17:40 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 01.10.2012, 10:39 GMT-4
Hello,

In "COMSOL Multiphysics Scripting Guide" you have a lot of (and useful) help. You can ask some more specific question, if you have any.

Luck,

Jesus.
Hello, In "COMSOL Multiphysics Scripting Guide" you have a lot of (and useful) help. You can ask some more specific question, if you have any. Luck, Jesus.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 02.10.2012, 05:41 GMT-4
My supervisor asked me to understand this m.fil in MATLAB.
geometry, boundary conditions, meshing, equations and time stepping. So how can i get to know these all things?
i want to understand each step in the programming. it is the part of my thesis and viva.

My supervisor asked me to understand this m.fil in MATLAB. geometry, boundary conditions, meshing, equations and time stepping. So how can i get to know these all things? i want to understand each step in the programming. it is the part of my thesis and viva.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 02.10.2012, 06:48 GMT-4
Hello,

An advice: save a very simple file as .m and open it in MATLAB. With the help of the Guide I mentioned, you will be able of understanding all the code.

Jesus.

Hello, An advice: save a very simple file as .m and open it in MATLAB. With the help of the Guide I mentioned, you will be able of understanding all the code. Jesus.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 03.10.2012, 03:34 GMT-4
the guide u mentioned can be found where?

For diffusion equation with initial condition sin(pi*x) or 0.1, the graph is same. on clicking the tab solve, it gives only one curve. solving for both conditions i found, both curves are same. how is it possible? different inital conditions and same garph. i want to know, for the first time when we click solve, the graph appears is of wich time level?
If domain is 0:1, and time is from 0:0.01:1, the curve it gives is the solution on the whole domain, but at which time level?

it has become a matter of depression for me.
the guide u mentioned can be found where? For diffusion equation with initial condition sin(pi*x) or 0.1, the graph is same. on clicking the tab solve, it gives only one curve. solving for both conditions i found, both curves are same. how is it possible? different inital conditions and same garph. i want to know, for the first time when we click solve, the graph appears is of wich time level? If domain is 0:1, and time is from 0:0.01:1, the curve it gives is the solution on the whole domain, but at which time level? it has become a matter of depression for me.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 05.10.2012, 07:29 GMT-4
Hi, Subha,

As you marked version 3.5 in the topic, I answered about that version. As you will know, since version 4 COMSOL does not produce MATLAB code (.m files) nor can execute MATLAB code, unless you have the LiveLink for MATLAB. The guide I cited came with COMSOL distributions prior to version 4.
About the problem you mention, it seems that you change only initial conditions, not boundary cond. I understand that you perform a time-dependent simulation. If the stationary solution is convergent, different time-dependent simulations will tend to the same (the stationary) solution. I think this is what you are seeing.

Jesus.
Hi, Subha, As you marked version 3.5 in the topic, I answered about that version. As you will know, since version 4 COMSOL does not produce MATLAB code (.m files) nor can execute MATLAB code, unless you have the LiveLink for MATLAB. The guide I cited came with COMSOL distributions prior to version 4. About the problem you mention, it seems that you change only initial conditions, not boundary cond. I understand that you perform a time-dependent simulation. If the stationary solution is convergent, different time-dependent simulations will tend to the same (the stationary) solution. I think this is what you are seeing. Jesus.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 09.10.2012, 10:48 GMT-4
Hi
understanding, how to increase mesh in 1D, except refining it during model development in COMSOL. how can it be done? in m file how can we command the programme to increase the mesh and show in graph.

for example once it chooses free mesh, we save the programme in m.file, now we run it from COMSOL with MATLAB. if we are interested in increasing mesh and we wanto see the increased number of mesh in command window in figures and at the same time wanto see a graph of 1D which shows increased mesh points. how can we get the things of our requirement?

Subha
Hi understanding, how to increase mesh in 1D, except refining it during model development in COMSOL. how can it be done? in m file how can we command the programme to increase the mesh and show in graph. for example once it chooses free mesh, we save the programme in m.file, now we run it from COMSOL with MATLAB. if we are interested in increasing mesh and we wanto see the increased number of mesh in command window in figures and at the same time wanto see a graph of 1D which shows increased mesh points. how can we get the things of our requirement? Subha

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 09.10.2012, 11:51 GMT-4
HI, Subha

In COMSOL 3.5a (in an .m file) you can write:
fem.mesh = meshrefine(fem, 'mcase',0);
This code (and all the MATLAB code for this version of COMSOL) is explained in "MATLAB Interface Guide", but especially in the "Reference Guide", both of which you can find in the help documentation.

There you can find explanations and examples, like:

meshrefine(fem, 'tri', [1:50; ones(1,50)]); ,
meshrefine(fem, 'subdomain', [1 2], 'rmethod', 'longest'); , or
meshrefine(fem, 'subdomain',1);

Finally, you can get a graph of the mesh:
fem.mesh = meshrefine(fem, 'subdomain', [1 2], 'rmethod', 'longest');
figure, meshplot(fem)

Bye,

Jesus.
HI, Subha In COMSOL 3.5a (in an .m file) you can write: fem.mesh = meshrefine(fem, 'mcase',0); This code (and all the MATLAB code for this version of COMSOL) is explained in "MATLAB Interface Guide", but especially in the "Reference Guide", both of which you can find in the help documentation. There you can find explanations and examples, like: meshrefine(fem, 'tri', [1:50; ones(1,50)]); , meshrefine(fem, 'subdomain', [1 2], 'rmethod', 'longest'); , or meshrefine(fem, 'subdomain',1); Finally, you can get a graph of the mesh: fem.mesh = meshrefine(fem, 'subdomain', [1 2], 'rmethod', 'longest'); figure, meshplot(fem) Bye, Jesus.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 22.10.2012, 03:08 GMT-4
AOA

now i m worried about this error while solving Reaction diffusion equation with no flux boundaries, one D, non dimensional parameter with diffusion term i.e. Ds=0.1

Warning:
Failed to find a solution:
Maximum number of Newton iterations reached.
Returned solution has not converged.
> In femsolver at 382
In femstatic at 92
In reactiondiffusioncomsolsinpix at 84

Warning:
Failed to find a solution:
No convergence, even when using the minimum damping factor.
Returned solution has not converged.
> In femsolver at 382
In femstatic at 92
In reactiondiffusioncomsolsinpix at 84
>> %-- 10/22/12 11:21 AM --%

What it menas, ' graph shows nuthing except two circles on lower boundary and upper boundary'.
how to obtain the results?
AOA now i m worried about this error while solving Reaction diffusion equation with no flux boundaries, one D, non dimensional parameter with diffusion term i.e. Ds=0.1 Warning: Failed to find a solution: Maximum number of Newton iterations reached. Returned solution has not converged. > In femsolver at 382 In femstatic at 92 In reactiondiffusioncomsolsinpix at 84 Warning: Failed to find a solution: No convergence, even when using the minimum damping factor. Returned solution has not converged. > In femsolver at 382 In femstatic at 92 In reactiondiffusioncomsolsinpix at 84 >> %-- 10/22/12 11:21 AM --% What it menas, ' graph shows nuthing except two circles on lower boundary and upper boundary'. how to obtain the results?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 13.11.2012, 11:28 GMT-5
hi
how can some one challenge the results of COMSOL? means wht is the source of its validity?
regards
hi how can some one challenge the results of COMSOL? means wht is the source of its validity? regards

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 13.11.2012, 15:01 GMT-5
Hi
That is exactly the job of all engineers using such a tool. For each results one should have some other mean to check at least 1-3 points of the results to check its validity. One way is to check it on a simple model, but representative for the detailed mode, and that is known from an analytical development. Or one make some simple analysis with a tools such as Maple, or MapleSim or any Modelica based solver, which covers somewhat the domain (in a more "lumped" simplified way) of COMSOL.


--
Good luck
Ivar
Hi That is exactly the job of all engineers using such a tool. For each results one should have some other mean to check at least 1-3 points of the results to check its validity. One way is to check it on a simple model, but representative for the detailed mode, and that is known from an analytical development. Or one make some simple analysis with a tools such as Maple, or MapleSim or any Modelica based solver, which covers somewhat the domain (in a more "lumped" simplified way) of COMSOL. -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.11.2012, 13:43 GMT-5
hi
can we use comsol for solving ordinary diff equation solutions? growth and logistic growth models... can u teach me how to use comsol for this purpose?

regards
hi can we use comsol for solving ordinary diff equation solutions? growth and logistic growth models... can u teach me how to use comsol for this purpose? regards

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.11.2012, 11:56 GMT-5
plz guide me how can i use comsol 3.5 for ODE equations solution. i wanto get results of malthus model then logistic growth model. plz tell me in steps i searched for odes mode in comsol but found nothing.
plz help.
regards
plz guide me how can i use comsol 3.5 for ODE equations solution. i wanto get results of malthus model then logistic growth model. plz tell me in steps i searched for odes mode in comsol but found nothing. plz help. regards

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.11.2012, 12:19 GMT-5
Hello, Subha,

It's easy. Follow these steps:

1. Open any space dimension, for instance 1D (you will use no dimension at all, as you only will solve ordinary differential equations).

2. Open any physics with time dependent analysis, for instance:
New > COMSOL Mult. > PDE Modes > PDE, Coefficient Form > Time-dependent analysis > OK
This is only to tell COMSOL to start with a time-dependent analysis, although you are not using this physics later.

3. Draw any geometry, for instance only a point.

4. Go to menu: Physics > Global Equations: write here your dependent variable (1st field), its ord. differential equation (2nd field) and its initial values (fields 3rd and 4th).

5. In Menu: Solve > Solve Manager > Solve For: select only your ODE (not PDE ...)

6. In Menu: Solve > Solver Parameters > Time Dependent > General: set the times for which you want to solve.

7. Solve.

8. In Menu: Postprocessing > Global Variables Plot: select your variable (for instance u) and slect OK.

I hope this helps you.

Jesus.

Hello, Subha, It's easy. Follow these steps: 1. Open any space dimension, for instance 1D (you will use no dimension at all, as you only will solve ordinary differential equations). 2. Open any physics with time dependent analysis, for instance: New > COMSOL Mult. > PDE Modes > PDE, Coefficient Form > Time-dependent analysis > OK This is only to tell COMSOL to start with a time-dependent analysis, although you are not using this physics later. 3. Draw any geometry, for instance only a point. 4. Go to menu: Physics > Global Equations: write here your dependent variable (1st field), its ord. differential equation (2nd field) and its initial values (fields 3rd and 4th). 5. In Menu: Solve > Solve Manager > Solve For: select only your ODE (not PDE ...) 6. In Menu: Solve > Solver Parameters > Time Dependent > General: set the times for which you want to solve. 7. Solve. 8. In Menu: Postprocessing > Global Variables Plot: select your variable (for instance u) and slect OK. I hope this helps you. Jesus.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.11.2012, 12:56 GMT-5
hi
suppose my equation is logistic growth equation
1. ok
2.ok
3. ok

4. go to physics menu > global equation : field 1 name(i wrote, N), field 2 equation (i wrote, dN/dt= N(1-N)), field 3 init N (i wote, 0.5) , field 4 init Nt (i wrote, 0)
is it ok?

5. In Menu: Solve > Solve Manager > Solve For: select only your ODE (not PDE ...)....... note you did not tell, with out solve, in solve manager window what to click after slecting only ode, solve? cancl? apply? ok? help? what to click here at end?

6. In Menu: Solve > Solver Parameters > Time Dependent > General: set the times for which you want to solve. this window does not contain any solve button??

7. Solve.

8. In Menu: Postprocessing > Global Variables Plot: select your variable (for instance u) and slect OK. note i cannot see any field which asks about variable? vaiable dependent or independent?

please reply....
hi suppose my equation is logistic growth equation 1. ok 2.ok 3. ok 4. go to physics menu > global equation : field 1 name(i wrote, N), field 2 equation (i wrote, dN/dt= N(1-N)), field 3 init N (i wote, 0.5) , field 4 init Nt (i wrote, 0) is it ok? 5. In Menu: Solve > Solve Manager > Solve For: select only your ODE (not PDE ...)....... note you did not tell, with out solve, in solve manager window what to click after slecting only ode, solve? cancl? apply? ok? help? what to click here at end? 6. In Menu: Solve > Solver Parameters > Time Dependent > General: set the times for which you want to solve. this window does not contain any solve button?? 7. Solve. 8. In Menu: Postprocessing > Global Variables Plot: select your variable (for instance u) and slect OK. note i cannot see any field which asks about variable? vaiable dependent or independent? please reply....

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.11.2012, 13:15 GMT-5
Hi,

In step 4, correct your equation: it should be
Nt-N+N*N
, as Nt means derivative w.r.t. time and you have to enter the expression which is null-valued.

In step 5: after selecting only ODE, press OK.

In step 6: select your times and press OK.

Step 7. Press the SOLVE button (symbol "="), or in Menu > Solve > Solve Problem.

Try these steps, please.

Jesus.
Hi, In step 4, correct your equation: it should be Nt-N+N*N , as Nt means derivative w.r.t. time and you have to enter the expression which is null-valued. In step 5: after selecting only ODE, press OK. In step 6: select your times and press OK. Step 7. Press the SOLVE button (symbol "="), or in Menu > Solve > Solve Problem. Try these steps, please. Jesus.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.11.2012, 13:34 GMT-5
hi

In step 4, correct your equation: it should be
Nt-N+N*N
, as Nt means derivative w.r.t. time and you have to enter the expression which is null-valued.

In step 5: after selecting only ODE, press OK.

In step 6: select your times and press OK.

Step 7. Press the SOLVE button (symbol "="), or in Menu > Solve > Solve Problem.

it gives error
duplicate variable
N
Nt
Ntt
n
Nt
Ntt
variables are repeated?

for step 4
----------------------------------------------------------------------------------------------------------------------------------------------------------
Name (u) equation f(u,ut,utt,, t) init (u) init (ut)
----------------------------------------------------------------------------------------------------------------------------------------------------------
N Nt - N + N*N 0.5 ?
-----------------------------------------------------------------------------------------------------------------------------------------------------------
please correct if wrong.

regards
hi In step 4, correct your equation: it should be Nt-N+N*N , as Nt means derivative w.r.t. time and you have to enter the expression which is null-valued. In step 5: after selecting only ODE, press OK. In step 6: select your times and press OK. Step 7. Press the SOLVE button (symbol "="), or in Menu > Solve > Solve Problem. it gives error duplicate variable N Nt Ntt n Nt Ntt variables are repeated? for step 4 ---------------------------------------------------------------------------------------------------------------------------------------------------------- Name (u) equation f(u,ut,utt,, t) init (u) init (ut) ---------------------------------------------------------------------------------------------------------------------------------------------------------- N Nt - N + N*N 0.5 ? ----------------------------------------------------------------------------------------------------------------------------------------------------------- please correct if wrong. regards

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.11.2012, 13:40 GMT-5
See the image attached.

Good weekend.

Jesus
See the image attached. Good weekend. Jesus


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 17.11.2012, 01:37 GMT-5
hi

the similar i did. but error duplicate variables. how to handle it?

tc
hi the similar i did. but error duplicate variables. how to handle it? tc

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 17.11.2012, 01:39 GMT-5
Sir how can i learn usinf comsol efficiently. for me teacher is better is than book. do u give online classes?
Sir how can i learn usinf comsol efficiently. for me teacher is better is than book. do u give online classes?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 17.11.2012, 02:09 GMT-5
her is the error i m haveing

Error: 6164
Duplicate variable name.
varaible:N
varaible:Nt
varaible:Ntt
varaible:N
varaible:Nt
varaible:Ntt
how to handle it.


note : in draw section: for my equation dN/dt=N(1-N), i drew a line from 0 - 1
this represents length of independent varable t . then on page Solver parameter
field: Times= 0:0.001:1
field: Relative tolerance: 0.01, by default (should it remain the same)
field: Absolute tolerance: 0.0010 , by default (should it remain the same)
after this press OK?

please notify if i m wrong at some step.
regards

her is the error i m haveing Error: 6164 Duplicate variable name. varaible:N varaible:Nt varaible:Ntt varaible:N varaible:Nt varaible:Ntt how to handle it. note : in draw section: for my equation dN/dt=N(1-N), i drew a line from 0 - 1 this represents length of independent varable t . then on page Solver parameter field: Times= 0:0.001:1 field: Relative tolerance: 0.01, by default (should it remain the same) field: Absolute tolerance: 0.0010 , by default (should it remain the same) after this press OK? please notify if i m wrong at some step. regards

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 17.11.2012, 04:44 GMT-5
Hi

Duplicated variables means as stated: a variable has been defined several places.

Many variables are defined internally by COMSOL, so these names should not bre reused, at least not in a varaible declaration. In contrary to a Parameter, which can be overwritten later, one shall not declare a user variable name with a COMSOL name (at least that is my understanding)
You can degine Global varaible high up in the node tree, these are defined for any model, so are generally space variable independent

You can define local variabbles under each model in a file, these are either scalars, or fields depending on the model geoemtry, or time or ...

But in anycase names should be unique. In V4 (probably also v3) names are tagged as préfix in v4 and suffix in v3 such that one can define some exceptions above. As a local variable with one name can take different expressions for different entities (domains, subdomains/boundaries ...

To lear COMSOl its worth to take a few chapter of the user manual per day, in small doses, then t reapet the reading 2-3 times over a year, as at each reading you discover new things you didi think of during the first reading.

Comsol convention for doing math, and with their unified physics layers ontop is very nice, but needs some time to learn, even if I finally find it close to my math/physics teaching, once I have identified the correct links

--
Good luck
Ivar
Hi Duplicated variables means as stated: a variable has been defined several places. Many variables are defined internally by COMSOL, so these names should not bre reused, at least not in a varaible declaration. In contrary to a Parameter, which can be overwritten later, one shall not declare a user variable name with a COMSOL name (at least that is my understanding) You can degine Global varaible high up in the node tree, these are defined for any model, so are generally space variable independent You can define local variabbles under each model in a file, these are either scalars, or fields depending on the model geoemtry, or time or ... But in anycase names should be unique. In V4 (probably also v3) names are tagged as préfix in v4 and suffix in v3 such that one can define some exceptions above. As a local variable with one name can take different expressions for different entities (domains, subdomains/boundaries ... To lear COMSOl its worth to take a few chapter of the user manual per day, in small doses, then t reapet the reading 2-3 times over a year, as at each reading you discover new things you didi think of during the first reading. Comsol convention for doing math, and with their unified physics layers ontop is very nice, but needs some time to learn, even if I finally find it close to my math/physics teaching, once I have identified the correct links -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19.11.2012, 05:09 GMT-5
hi
o mesh points
--- mesh elememnts

every two points make one mesh element.
i wanto know for 1D model in 'x' how domain e.g 0<x<1 is divided into number of mesh elements. initialse mesh is done it uses which formula to divide this domain and into how many pieces? after refine mesh how many more mesh elemnts this domain i divided?
the divided domain is divided into straight small lines?
e.g
0_____________________1
o------o------o------o------o------o
suppose this 0<x<1 domain is divided 5 mesh elements and 6 mesh points out of whihc two are boundaries.
what formula is used to divide this domain, what is the distance between every two mesh points ( o---dx---o)
hoe can we calculate this distance?
plz guide
hi o mesh points --- mesh elememnts every two points make one mesh element. i wanto know for 1D model in 'x' how domain e.g 0

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 19.11.2012, 05:56 GMT-5
Hi

you need to read the doc, the user guide about the meshing, you have different methods to define a regular or controlled meshing distribution.

Now COMSOL does not give you direct access to the mesh items, you are supposed to do physics with COMSOL and not FEM development (as one would do for a calssical FEM tool). This is really the strength of COMSOL, you can concentrate on the physics and leave COMSOL math compiler look after the FEM.
But you do need to ensure that your discretization values are correct, and that your overall mesh densities are coherent with the dependent variables and their gradients

--
Good luck
Ivar
Hi you need to read the doc, the user guide about the meshing, you have different methods to define a regular or controlled meshing distribution. Now COMSOL does not give you direct access to the mesh items, you are supposed to do physics with COMSOL and not FEM development (as one would do for a calssical FEM tool). This is really the strength of COMSOL, you can concentrate on the physics and leave COMSOL math compiler look after the FEM. But you do need to ensure that your discretization values are correct, and that your overall mesh densities are coherent with the dependent variables and their gradients -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19.11.2012, 06:13 GMT-5
is it possible that i compare the results of analytic results obtained from MATLAB and numeric results obtained from COMSOL. i m also trying to compare these results by error plots.

i m confused, when i prepare a code for analytic solution in m file for non dimensional diffusion equation, for 0<x <1, it needs dt, dx. suppose i take dx = 0.001 this will equally divide the domain into 1000 grids.
where as in comsol how this divided? what is dx? can this be matched? either this dx for COMSOL is equally spaced or not?
is it possible that i compare the results of analytic results obtained from MATLAB and numeric results obtained from COMSOL. i m also trying to compare these results by error plots. i m confused, when i prepare a code for analytic solution in m file for non dimensional diffusion equation, for 0

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 20.11.2012, 01:23 GMT-5
Hi

first you shouldnt call results from matlab "analytical" they are as "numerical" as you can get from COMSOL, perhaps with Mathematica or Maple you should call it "analytical"

Clair if you use a fixed stepping matlab code you need equally spaced data, the nice thing with COMSOL is that you do not need to bother about the math (the numerical algorithm ...) COMSOL has many different solvers.

Now its perfectly possible to use a fixed spacing grid in COMSOL, you need to define the mesh distribution accordingly, and go get the time stepper you need to use strict equally spaced time steps, but then you are removing most of the freedom you have in COMSOL. It remains perfectly possible. The only thing for me is that I havent used v3 now for a few years so I cannot really remember the subtilities of the settings to select this. But it's described in the doc, and the 3.5a doc was rather complete

--
Good luck
Ivar
Hi first you shouldnt call results from matlab "analytical" they are as "numerical" as you can get from COMSOL, perhaps with Mathematica or Maple you should call it "analytical" Clair if you use a fixed stepping matlab code you need equally spaced data, the nice thing with COMSOL is that you do not need to bother about the math (the numerical algorithm ...) COMSOL has many different solvers. Now its perfectly possible to use a fixed spacing grid in COMSOL, you need to define the mesh distribution accordingly, and go get the time stepper you need to use strict equally spaced time steps, but then you are removing most of the freedom you have in COMSOL. It remains perfectly possible. The only thing for me is that I havent used v3 now for a few years so I cannot really remember the subtilities of the settings to select this. But it's described in the doc, and the 3.5a doc was rather complete -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23.11.2012, 03:45 GMT-5
aoa

i m wondring diffusion equation results from comsol, and analytic result.
how these two plots can be ploted in one graph?
regards
aoa i m wondring diffusion equation results from comsol, and analytic result. how these two plots can be ploted in one graph? regards

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 23.11.2012, 07:42 GMT-5
Hi

I would say export either the COMSOl to excel or some other tool (MAPLE ? ...) or solve your analytical equation in a column csv file and import the analytical solution into an interpolation function into COMSOL.
Now if your analytical equation can be expressed as a COMSOL PDE or ODE, then solve it in COMSOL, but thats looping around perhaps, ideally you should use another tool (it's just that it's so much quicker in COMSOL, once you have learned to use it ;)

--
Good luck
Ivar
Hi I would say export either the COMSOl to excel or some other tool (MAPLE ? ...) or solve your analytical equation in a column csv file and import the analytical solution into an interpolation function into COMSOL. Now if your analytical equation can be expressed as a COMSOL PDE or ODE, then solve it in COMSOL, but thats looping around perhaps, ideally you should use another tool (it's just that it's so much quicker in COMSOL, once you have learned to use it ;) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23.11.2012, 09:48 GMT-5
i did plot my analytic result in MATLAB with the help of small code. and numeric result plot is obtained from COMSOL.
now i m asked to plot these plots in one graph window to see the difference in analytic and numeric results.
how can both be done in one graph?
i did plot my analytic result in MATLAB with the help of small code. and numeric result plot is obtained from COMSOL. now i m asked to plot these plots in one graph window to see the difference in analytic and numeric results. how can both be done in one graph?

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 23.11.2012, 13:47 GMT-5
Hello

If you can write it in Matlab there is a fair chance you can also in COMSOL, or you can export your graph data to a text file and import it in COMSOL via an interpolation function, then you can plot both functions on the same graph

--
Good luck
Ivar
Hello If you can write it in Matlab there is a fair chance you can also in COMSOL, or you can export your graph data to a text file and import it in COMSOL via an interpolation function, then you can plot both functions on the same graph -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23.11.2012, 14:21 GMT-5
i did it in some other way , in comsol code , in my time loop for plotting number of curves i added my analytic code into the same loop. it did work, comsol first plot analytic curves, then one by one numeric curves on it.

but u told i would like to try. can u plz tell me if i can try that interpolation method. if just tell me in steps that how can i export my data from matlab to comsol. and how to use interpolation.

i shall be very thank ful to u
i did it in some other way , in comsol code , in my time loop for plotting number of curves i added my analytic code into the same loop. it did work, comsol first plot analytic curves, then one by one numeric curves on it. but u told i would like to try. can u plz tell me if i can try that interpolation method. if just tell me in steps that how can i export my data from matlab to comsol. and how to use interpolation. i shall be very thank ful to u

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 23.11.2012, 17:40 GMT-5
Hi

sorry but if you are in 3.5 that is now too old for me to remember, and I do not have 3.5 up running any longer. Check the doc for interpolation function, in V4 its really easy, but I believe it was there for v3 too

--
Good luck
Ivar
Hi sorry but if you are in 3.5 that is now too old for me to remember, and I do not have 3.5 up running any longer. Check the doc for interpolation function, in V4 its really easy, but I believe it was there for v3 too -- Good luck Ivar

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.