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.

Need to run lot of simulations

Please login with a confirmed email address before reporting spam

Hi,
I need to run a lot of COMSOL simulations by changing some parameters. Is there some way COMSOL can read the values from an EXCEL/text file and do the simulations automatically. That way, I can run the simulations all night without being required to change parameters each time a simulation ends.

Regards

5 Replies Last Post 24 nov. 2011, 02:30 UTC−5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 nov. 2011, 10:42 UTC−5
This is exactly what I'd like to know as well!

I think something like this would be possible via Livelink for Matlab (where you open COMSOL model in Matlab and essentially run your "macro" scripts via .m files). When I get time in the next days I plan on trying the Livelink, but doing this natively in COMSOl using just a txt would be great.

Ideal would be something like "COMSOL, please vary my current between 1 and 10 mA in increments of 1 mA, and for each simulation output/save me this certain plot, all overnight while I'm away."



Hi,
I need to run a lot of COMSOL simulations by changing some parameters. Is there some way COMSOL can read the values from an EXCEL/text file and do the simulations automatically. That way, I can run the simulations all night without being required to change parameters each time a simulation ends.

Regards


This is exactly what I'd like to know as well! I think something like this would be possible via Livelink for Matlab (where you open COMSOL model in Matlab and essentially run your "macro" scripts via .m files). When I get time in the next days I plan on trying the Livelink, but doing this natively in COMSOl using just a txt would be great. Ideal would be something like "COMSOL, please vary my current between 1 and 10 mA in increments of 1 mA, and for each simulation output/save me this certain plot, all overnight while I'm away." [QUOTE] Hi, I need to run a lot of COMSOL simulations by changing some parameters. Is there some way COMSOL can read the values from an EXCEL/text file and do the simulations automatically. That way, I can run the simulations all night without being required to change parameters each time a simulation ends. Regards [/QUOTE]

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 nov. 2011, 12:07 UTC−5
With the Matlab LiveLink this should indeed be an easy thing to do. It's just a couple of lines of code: load Comsol .mph file, change parameter value, solve, save to new file... rinse and repeat.

However, I usually prefer to use comsolbatch for these kinds of things. After all, this is what comsolbatch is for. You get a nice log file for each run and, unlike the Matlab / Comsol server combination, it's not leaking memory like a sieve.

The comsolbatch command line help (and the documentation as well) mentions the following two command line options:
-pname <parameter name> Comma separated list of parameter names
-plist <parameter values> Comma separated list of parameter values

This is pretty much the extent of what the documentation has to say on this topic. And while it sounds exactly like what we are looking for in this thread, I never got it to work.

So I always worked around it by simply setting up several copies of the same (unsolved) model for each parameter value, and then batch-run those files over night. If the list of values is not too long, it doesn't cost much time to set up the files. However, it would be nice if someone could explain how the above-mentioned command line options are supposed to work.
With the Matlab LiveLink this should indeed be an easy thing to do. It's just a couple of lines of code: load Comsol .mph file, change parameter value, solve, save to new file... rinse and repeat. However, I usually prefer to use comsolbatch for these kinds of things. After all, this is what comsolbatch is for. You get a nice log file for each run and, unlike the Matlab / Comsol server combination, it's not leaking memory like a sieve. The comsolbatch command line help (and the documentation as well) mentions the following two command line options: [quote]-pname Comma separated list of parameter names -plist Comma separated list of parameter values[/quote] This is pretty much the extent of what the documentation has to say on this topic. And while it sounds exactly like what we are looking for in this thread, I never got it to work. So I always worked around it by simply setting up several copies of the same (unsolved) model for each parameter value, and then batch-run those files over night. If the list of values is not too long, it doesn't cost much time to set up the files. However, it would be nice if someone could explain how the above-mentioned command line options are supposed to work.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 nov. 2011, 17:13 UTC−5
Thanks John! How do I batch run the unsolved files after saving all the files (with different parameters)
Thanks.
Thanks John! How do I batch run the unsolved files after saving all the files (with different parameters) Thanks.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 23 nov. 2011, 23:17 UTC−5
How do I run files using batch command. I can just put one filename while running batch command. I need to different files overnight.
How do I run files using batch command. I can just put one filename while running batch command. I need to different files overnight.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 nov. 2011, 02:30 UTC−5
Hi Nitesh,

I posted the command line scripts I use to batch-run multiple models in the following thread:
www.comsol.com/community/forums/general/thread/13315/

But basically, what you just have to do is, instead of calling comsolbatch directly on the command prompt as you do for one model, you write that very command line into a text file, name the file something like "batch.cmd", copy-&-paste that first line for all the other models you want to run, edit the lines, and finally run "batch.cmd" to solve all models in one go.

The scripts I posted in the other thread just save you the time of creating the "batch.cmd" command line script, because usually you want to solve all models contained in a given folder.
Hi Nitesh, I posted the command line scripts I use to batch-run multiple models in the following thread: [quote]http://www.comsol.com/community/forums/general/thread/13315/[/quote] But basically, what you just have to do is, instead of calling comsolbatch directly on the command prompt as you do for one model, you write that very command line into a text file, name the file something like "batch.cmd", copy-&-paste that first line for all the other models you want to run, edit the lines, and finally run "batch.cmd" to solve all models in one go. The scripts I posted in the other thread just save you the time of creating the "batch.cmd" command line script, because usually you want to solve all models contained in a given folder.

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.