Difference between revisions of "Comsol-Matlab tutorial"

From Applied Optics Wiki
Jump to: navigation, search
Line 9: Line 9:
 
===Building a model===
 
===Building a model===
  
There is no particular correct way to build your model in a CM interface, it is not all that intuitive. Personally, I have found that the best way to work with and build models is within a standard Comsol session. Once built a model can easily be manipulated within the CM interface. The internal language used by Comsol is fully compatible with Matlab script, and as you build a model Comsol saves the commands in a Matlab usable format in a file named ''myModel_history.m''.  
+
There is no particular correct way to build your model in a CM interface, it is not all that intuitive. Personally, I have found that the best way to work with and build models is within a standard Comsol session. Once built a model can easily be manipulated within the CM interface. The internal language used by Comsol is fully compatible with Matlab script, and as you build a model Comsol saves the commands in a Matlab usable format in a file named ''myModel_history.m''. I have uploaded an example script here [[File:JcModel history.txt]].
  
 
===Memory issues===
 
===Memory issues===

Revision as of 14:23, 7 January 2013

Setting up the software

The first step is installing the correct software. You will require a licensed copy of Comsol 3.5a, and a licensed copy of Matlab 2007. Both of these can be installed from the VPM repo.

A Comsol-Matlab (CM) interface is initialised by running the command comsol_35a matlab. This should start a java instance of Matlab 2007 with Comsol commands enabled. To check the link try the command flclear fem which will not work in a standard Matlab instance.

Within the CM interface all Matlab functionality is unchanged. In addition to this a new set of Comsol commands are available, all of which are documented and have standard help functionality.

Building a model

There is no particular correct way to build your model in a CM interface, it is not all that intuitive. Personally, I have found that the best way to work with and build models is within a standard Comsol session. Once built a model can easily be manipulated within the CM interface. The internal language used by Comsol is fully compatible with Matlab script, and as you build a model Comsol saves the commands in a Matlab usable format in a file named myModel_history.m. I have uploaded an example script here File:JcModel history.txt.

Memory issues