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.

Simple example to solve ODE

Please login with a confirmed email address before reporting spam

Hi,

I am a complete newbie with COMSOL (I have the MultiPhysics module, version 4.3a), and I have only followed some initial tutorial examples in the manual (e.g. "the wrench").
However, as I understood, there are also ways to solve ODEs (ordinary differential equations). I wanted to start with something really simple, and on the internet I found some example involving the predatory model:
#rabbits: dr/dt = a*r - b*r*f
#foxes: df/dt = -c*f + d*r*f
However, the example I found is clearly meant for a different COMSOL version because the description of buttons/menus to use does not correspond to my version.
To give it a go anyway, I used the "Global ODEs and DAEs" node, and in the "Global Equations 1" settings window, defined:
r*(a-b*f)-rt (initial value r: 100, initial value rt: 0)
-f*(c-d*r)-ft (initial value f: 100, initial value ft: 0)
My question is (and this might come from a complete misunderstanding of how COMSOL works):
- Where do I define the upper and lower bounds for t? (In the geometry, but how?)
- how do I get a plot showing r and f versus t? (Do I need to use "parameter sweep" for this?)
- Is it possible to just solve a 1-D ODE without selecting any kind of other physics models?
- Is there any example around for version 4.3a?
- (I actually tried to just click on "Study1->Calculate" and while the program does not complain, I also have no idea how to get the plot I want)

Best regards,

Machiel

2 Replies Last Post 13 mai 2013, 09:32 UTC−4
Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 13 mai 2013, 04:15 UTC−4
Hi,

Regarding your questions:

1. Where do I define the upper and lower bounds for t? (In the geometry, but how?)

You add a Time Dependent study to the model (directly in the Model Wizard or by right-clicking the root node in the model tree). Then you define the times in the settings window for the Step 1: Time Dependent node; the default setting is "range(0,0.1,1), which means that time runs from 0 to 1 s with steps of 0.1 s.

2. How do I get a plot showing r and f versus t? (Do I need to use "parameter sweep" for this?)

No, a 1D Plot Group with a Global plot node should appear automatically. In the settings window for the Global node, you can add r and f as the state variables mod1.r and mod1.f (in the table of expressions under "y-Axis Data") to plot both of them as a plot of r and f versus t.

3. Is it possible to just solve a 1-D ODE without selecting any kind of other physics models?

Yes, you can add just an Global ODEs and DAEs user interface (and then select 0D as the model's geometry dimension if you have no geometry).

4. Is there any example around for version 4.3a?

This predator-prey model is described in the COMSOL documentation as the Lotka-Volterra equations. The documentation shows how to enter the equations in the settings window for Global Equations.

5. (I actually tried to just click on "Study1->Calculate" and while the program does not complain, I also have no idea how to get the plot I want)

This is probably because there is no Time Dependent study in your model, but I'm not sure.

Hope this helps.

Best regards,
Magnus Ringh, COMSOL
Hi, Regarding your questions: 1. Where do I define the upper and lower bounds for t? (In the geometry, but how?) You add a Time Dependent study to the model (directly in the Model Wizard or by right-clicking the root node in the model tree). Then you define the times in the settings window for the Step 1: Time Dependent node; the default setting is "range(0,0.1,1), which means that time runs from 0 to 1 s with steps of 0.1 s. 2. How do I get a plot showing r and f versus t? (Do I need to use "parameter sweep" for this?) No, a 1D Plot Group with a Global plot node should appear automatically. In the settings window for the Global node, you can add r and f as the state variables mod1.r and mod1.f (in the table of expressions under "y-Axis Data") to plot both of them as a plot of r and f versus t. 3. Is it possible to just solve a 1-D ODE without selecting any kind of other physics models? Yes, you can add just an Global ODEs and DAEs user interface (and then select 0D as the model's geometry dimension if you have no geometry). 4. Is there any example around for version 4.3a? This predator-prey model is described in the COMSOL documentation as the Lotka-Volterra equations. The documentation shows how to enter the equations in the settings window for Global Equations. 5. (I actually tried to just click on "Study1->Calculate" and while the program does not complain, I also have no idea how to get the plot I want) This is probably because there is no Time Dependent study in your model, but I'm not sure. Hope this helps. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 13 mai 2013, 09:32 UTC−4

Thank you very much. You were right, what was missing was the Time Dependent study.
Best regards,

Machiel
Thank you very much. You were right, what was missing was the Time Dependent study. Best regards, Machiel

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.