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 use COMSOL batch to solve many files repeatedly without GUI?

Please login with a confirmed email address before reporting spam

Hi,

When I open an .mph file with a given geometry and settings, then click "Solve", COMSOL creates the mesh then solves the problem.
I would like to do this in batch mode (i.e., without GUI), however, I am not successful.

I think I should use something like "comsol batch -input myfile.mph" and that should suffice, however, COMSOL quits saying that the file doesn't contain a mesh. The COMSOL help files state that the .mph file's geometry must be meshed before using the above to solve the project.

Can anyone explain how may I *simply* tell COMSOL to open file after file after file, *create a mesh* and solve each?

Thank you

27 Replies Last Post 22 août 2017, 04:24 UTC−4
COMSOL Moderator

Hello Roy Shiloh

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 6 avr. 2011, 06:00 UTC−4
Hi,

I don't have a solution for your question, since I wanted to ask you about Batch. How can it be useful when it comes to repeated tasks. Actually I read the documentation, there's no solid information there. Is there some guide to learn how batching really works (i.e. does it need a Matlab code ? )

--
Regards
Ali
(v4.0a)
Hi, I don't have a solution for your question, since I wanted to ask you about Batch. How can it be useful when it comes to repeated tasks. Actually I read the documentation, there's no solid information there. Is there some guide to learn how batching really works (i.e. does it need a Matlab code ? ) -- Regards Ali (v4.0a)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 6 avr. 2011, 06:32 UTC−4
AFAIK the batch option is only useful if you have any number of .mph files already meshed, and all you want to do is solve them. This saves you the trouble of opening comsol, clicking open, clicking solve, clicking save, then repeating.
AFAIK the batch option is only useful if you have any number of .mph files already meshed, and all you want to do is solve them. This saves you the trouble of opening comsol, clicking open, clicking solve, clicking save, then repeating.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25 avr. 2011, 19:23 UTC−4
Hi Roy Shiloh

I don't know if you have found the solution for batch processing.
In version 4.1 of COMSOL, there is a tutorial model and pdf for batch operation called the micromixer
under Fluid Dynamics and Tutorial Modes.
I am myself trying to learn from that now.
if you have come across a better option, please let me know.

Thanks,
Kirthika.

Hi Roy Shiloh I don't know if you have found the solution for batch processing. In version 4.1 of COMSOL, there is a tutorial model and pdf for batch operation called the micromixer under Fluid Dynamics and Tutorial Modes. I am myself trying to learn from that now. if you have come across a better option, please let me know. Thanks, Kirthika.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 4 sept. 2011, 12:21 UTC−4

Hi,

When I open an .mph file with a given geometry and settings, then click "Solve", COMSOL creates the mesh then solves the problem.
I would like to do this in batch mode (i.e., without GUI), however, I am not successful.

I think I should use something like "comsol batch -input myfile.mph" and that should suffice, however, COMSOL quits saying that the file doesn't contain a mesh. The COMSOL help files state that the .mph file's geometry must be meshed before using the above to solve the project.

Can anyone explain how may I *simply* tell COMSOL to open file after file after file, *create a mesh* and solve each?

Thank you


Hi,
Have you worked out how to solve many .mph files repeatedly using COMSOL batch? I have the same problem now. I have built several .mph files already, and I want COMSOL to solve them one after one automatically.
[QUOTE] Hi, When I open an .mph file with a given geometry and settings, then click "Solve", COMSOL creates the mesh then solves the problem. I would like to do this in batch mode (i.e., without GUI), however, I am not successful. I think I should use something like "comsol batch -input myfile.mph" and that should suffice, however, COMSOL quits saying that the file doesn't contain a mesh. The COMSOL help files state that the .mph file's geometry must be meshed before using the above to solve the project. Can anyone explain how may I *simply* tell COMSOL to open file after file after file, *create a mesh* and solve each? Thank you [/QUOTE] Hi, Have you worked out how to solve many .mph files repeatedly using COMSOL batch? I have the same problem now. I have built several .mph files already, and I want COMSOL to solve them one after one automatically.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 4 sept. 2011, 13:43 UTC−4
I submit my jobs using the command:
comsol batch -inputfile myfile.mph.
If I have 2 files, I do it twice but looks like there is a better way to submit batch jobs automatically and am hoping someone can explain it.

Thanks,
Sirisha
I submit my jobs using the command: comsol batch -inputfile myfile.mph. If I have 2 files, I do it twice but looks like there is a better way to submit batch jobs automatically and am hoping someone can explain it. Thanks, Sirisha

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 4 sept. 2011, 22:36 UTC−4

I submit my jobs using the command:
comsol batch -inputfile myfile.mph.
If I have 2 files, I do it twice but looks like there is a better way to submit batch jobs automatically and am hoping someone can explain it.

Thanks,
Sirisha


I found out how to do it finally. For example, you have two .mph file (f1.mph, f2.mph) stored under E: \myfile to run, you can do like this: open the notepad, and input the command lines below:
comsolbatch -inputfile E:\myfile\f1.mph -outputfile E:\myfile\f1out.mph -batchlog E:\myfile\f1out.log
comsolbatch -inputfile E:\myfile\f2.mph -outputfile E:\myfile\f2out.mph -batchlog E:\myfile\f2out.log
store the file as f123.bat (for example), and put this file under the comsol installation directory, for example, C:\COMSOL42\bin\win32. When all of above are done, double click f123.bat, then you'll got what you want.
[QUOTE] I submit my jobs using the command: comsol batch -inputfile myfile.mph. If I have 2 files, I do it twice but looks like there is a better way to submit batch jobs automatically and am hoping someone can explain it. Thanks, Sirisha [/QUOTE] I found out how to do it finally. For example, you have two .mph file (f1.mph, f2.mph) stored under E: \myfile to run, you can do like this: open the notepad, and input the command lines below: comsolbatch -inputfile E:\myfile\f1.mph -outputfile E:\myfile\f1out.mph -batchlog E:\myfile\f1out.log comsolbatch -inputfile E:\myfile\f2.mph -outputfile E:\myfile\f2out.mph -batchlog E:\myfile\f2out.log store the file as f123.bat (for example), and put this file under the comsol installation directory, for example, C:\COMSOL42\bin\win32. When all of above are done, double click f123.bat, then you'll got what you want.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 5 sept. 2011, 12:00 UTC−4
Nice! I will try it out.
Nice! I will try it out.

Muhammad Mohsin Rehman

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 oct. 2011, 08:30 UTC−4
Hi Xiaoyi,

I am trying to build a model in COMSOL 4.0 using 2D geometry using Microwaves heating. I want to use model it in the way that I heat a fluid using microwaves and then after some time I want COMSOL to use another module. For example, in the start it should use the RF module and after some time, it should go for the Heat Transfer Module. Following this it should show the temperature distribution as a net result of both the modules.

Can you please suggest some thing for modelling this in COMSOL?

Many thanks in advance for any feedback!
Hi Xiaoyi, I am trying to build a model in COMSOL 4.0 using 2D geometry using Microwaves heating. I want to use model it in the way that I heat a fluid using microwaves and then after some time I want COMSOL to use another module. For example, in the start it should use the RF module and after some time, it should go for the Heat Transfer Module. Following this it should show the temperature distribution as a net result of both the modules. Can you please suggest some thing for modelling this in COMSOL? Many thanks in advance for any feedback!

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 oct. 2011, 21:37 UTC−4

Hi Xiaoyi,

I am trying to build a model in COMSOL 4.0 using 2D geometry using Microwaves heating. I want to use model it in the way that I heat a fluid using microwaves and then after some time I want COMSOL to use another module. For example, in the start it should use the RF module and after some time, it should go for the Heat Transfer Module. Following this it should show the temperature distribution as a net result of both the modules.

Can you please suggest some thing for modelling this in COMSOL?

Many thanks in advance for any feedback!


I think you can do it manually or automatically. For manual performance, stop the first running at the time you want to stop or you can directly set the time you want the first running to stop at the time range. For this first running, just check the RF module in the solver setting. For the second running, just check the Heat transfer module, and use the solution of the first running as the initial values of this running.
For automatic performance, maybe you can try to construct solver sequences, anyway I haven't try this.
[QUOTE] Hi Xiaoyi, I am trying to build a model in COMSOL 4.0 using 2D geometry using Microwaves heating. I want to use model it in the way that I heat a fluid using microwaves and then after some time I want COMSOL to use another module. For example, in the start it should use the RF module and after some time, it should go for the Heat Transfer Module. Following this it should show the temperature distribution as a net result of both the modules. Can you please suggest some thing for modelling this in COMSOL? Many thanks in advance for any feedback! [/QUOTE] I think you can do it manually or automatically. For manual performance, stop the first running at the time you want to stop or you can directly set the time you want the first running to stop at the time range. For this first running, just check the RF module in the solver setting. For the second running, just check the Heat transfer module, and use the solution of the first running as the initial values of this running. For automatic performance, maybe you can try to construct solver sequences, anyway I haven't try this.

Muhammad Mohsin Rehman

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25 oct. 2011, 07:00 UTC−4
Thanks Xiaoyi for answering!

If I go for manual setup and perform the first simulation (say for example for 100 seconds of heating time) and then get the results. How can I use this temperature distribution as input to the rest of the part of the geometry,which is only in the surrounding of the port area (temperature distribution in the case of RF module away from the source is zero)?

Please find attached an image(RF.jpeg) result of the first part which is related to Microwaves heating(RF Module). After the colored distribution of temperature, I want to start my Heat transfer module using the temperature distribution obtained from RF module and proceed further in the same model.

Can you please give some educated ideas of doing it, if you want to see the model files, I can make the files and post them to you as well?

I have also tried your tip to launch a batch process but I am unable to get the results according to the batch process. I am not sure how to start the batch process? I have saved two files in a folder with slightly different properties of materials (which are expected as a result of increase in temperature) and text file is saved as result.bat in the COMSOL Installation directory in the same format as you mentioned. Double clicking the batch file, I obtained the MS-DOS Window displaying two different commands (as shown in attached figure batch1.jpeg) but after a while this window disappears and nothing happens. I also tried to run both of the individual comsol files one by one but they are displaying just the usual results and no batching is taking place.

Can you please elaborate the procedure for my and other users' knowledge?
Thanks Xiaoyi for answering! If I go for manual setup and perform the first simulation (say for example for 100 seconds of heating time) and then get the results. How can I use this temperature distribution as input to the rest of the part of the geometry,which is only in the surrounding of the port area (temperature distribution in the case of RF module away from the source is zero)? Please find attached an image(RF.jpeg) result of the first part which is related to Microwaves heating(RF Module). After the colored distribution of temperature, I want to start my Heat transfer module using the temperature distribution obtained from RF module and proceed further in the same model. Can you please give some educated ideas of doing it, if you want to see the model files, I can make the files and post them to you as well? I have also tried your tip to launch a batch process but I am unable to get the results according to the batch process. I am not sure how to start the batch process? I have saved two files in a folder with slightly different properties of materials (which are expected as a result of increase in temperature) and text file is saved as result.bat in the COMSOL Installation directory in the same format as you mentioned. Double clicking the batch file, I obtained the MS-DOS Window displaying two different commands (as shown in attached figure batch1.jpeg) but after a while this window disappears and nothing happens. I also tried to run both of the individual comsol files one by one but they are displaying just the usual results and no batching is taking place. Can you please elaborate the procedure for my and other users' knowledge?


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25 oct. 2011, 23:22 UTC−4
Hi,
If I understand you correctly, you mean in your model the geometry for the RF module and for the Heat Transfer module is different, i.e., for the RF module, the geometry is the colored one, while for the Heat Transfer module, the geometry is the empty one, according to your RF.JPG. And what you want is transfer the temperature distribution in the colored geometry to the empty geometry as the initial values of the second simulation, right? If that, I don’t know how to do it, as you see, these two geometries have different size. Maybe you can contact the Comsol support for help.
For your second question, make sure you have input the command lines correctly. I found, from your batch1.JPG, in your first command line you missed .mph for the mw_batch1. You said “after a while this window disappears and nothing happens”, what do you mean for nothing happens? Have you checked the files mw_batch1out.mph and mw_batch2out.mph, since the simulation results will be stored in these two files.




Thanks Xiaoyi for answering!

If I go for manual setup and perform the first simulation (say for example for 100 seconds of heating time) and then get the results. How can I use this temperature distribution as input to the rest of the part of the geometry,which is only in the surrounding of the port area (temperature distribution in the case of RF module away from the source is zero)?

Please find attached an image(RF.jpeg) result of the first part which is related to Microwaves heating(RF Module). After the colored distribution of temperature, I want to start my Heat transfer module using the temperature distribution obtained from RF module and proceed further in the same model.

Can you please give some educated ideas of doing it, if you want to see the model files, I can make the files and post them to you as well?

I have also tried your tip to launch a batch process but I am unable to get the results according to the batch process. I am not sure how to start the batch process? I have saved two files in a folder with slightly different properties of materials (which are expected as a result of increase in temperature) and text file is saved as result.bat in the COMSOL Installation directory in the same format as you mentioned. Double clicking the batch file, I obtained the MS-DOS Window displaying two different commands (as shown in attached figure batch1.jpeg) but after a while this window disappears and nothing happens. I also tried to run both of the individual comsol files one by one but they are displaying just the usual results and no batching is taking place.

Can you please elaborate the procedure for my and other users' knowledge?


Hi, If I understand you correctly, you mean in your model the geometry for the RF module and for the Heat Transfer module is different, i.e., for the RF module, the geometry is the colored one, while for the Heat Transfer module, the geometry is the empty one, according to your RF.JPG. And what you want is transfer the temperature distribution in the colored geometry to the empty geometry as the initial values of the second simulation, right? If that, I don’t know how to do it, as you see, these two geometries have different size. Maybe you can contact the Comsol support for help. For your second question, make sure you have input the command lines correctly. I found, from your batch1.JPG, in your first command line you missed .mph for the mw_batch1. You said “after a while this window disappears and nothing happens”, what do you mean for nothing happens? Have you checked the files mw_batch1out.mph and mw_batch2out.mph, since the simulation results will be stored in these two files. [QUOTE] Thanks Xiaoyi for answering! If I go for manual setup and perform the first simulation (say for example for 100 seconds of heating time) and then get the results. How can I use this temperature distribution as input to the rest of the part of the geometry,which is only in the surrounding of the port area (temperature distribution in the case of RF module away from the source is zero)? Please find attached an image(RF.jpeg) result of the first part which is related to Microwaves heating(RF Module). After the colored distribution of temperature, I want to start my Heat transfer module using the temperature distribution obtained from RF module and proceed further in the same model. Can you please give some educated ideas of doing it, if you want to see the model files, I can make the files and post them to you as well? I have also tried your tip to launch a batch process but I am unable to get the results according to the batch process. I am not sure how to start the batch process? I have saved two files in a folder with slightly different properties of materials (which are expected as a result of increase in temperature) and text file is saved as result.bat in the COMSOL Installation directory in the same format as you mentioned. Double clicking the batch file, I obtained the MS-DOS Window displaying two different commands (as shown in attached figure batch1.jpeg) but after a while this window disappears and nothing happens. I also tried to run both of the individual comsol files one by one but they are displaying just the usual results and no batching is taking place. Can you please elaborate the procedure for my and other users' knowledge? [/QUOTE]

Muhammad Mohsin Rehman

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25 oct. 2011, 23:50 UTC−4
Thanks a lot Xiaoyi for your feedback!

In the geometry it is only one geometry with one fluid inside the box but I am getting the temperature distribution only in the area across the boundaries of source.There is no temperature change deep into the fluid after 10-15 cm. I want that as the initial heat propagation across the boundaries has been done by radiation heat transfer, similarly the rest of heat transfer should be done by conduction and/ or convection deep into the fluid as radiations will not reach deep in to the fluid. Does COMSOL consider it automatically or should I have to incorporate it by myself? If I have to do it by myself, how can I do that, any idea?

For the batch processing, I have made the correction in the batch file but still did not get any thing as I am confused about the process. I will write in detail what I did, please correct me if I am wrong?

I have two comsol files which I want comsol to run one after the other by using batch processing. I have stored them in D drive. I wrote the lines mentioned in the attached word document and stored it as batch.bat in the C:\COMSOL40a\bin\win32 directory.

Then I run this bat file, it opens DOS window with two lines appearing on the screen one after the other as shown in the figure and vanishes after a moment. Then I checked my folde of D drive where I have stored my comsol files but there are no out put files available. Should I make two COMSOL files as output as well? If yes, should they be empty?

Please clarify the whole procedure.

I will be obliged to you.

Thanks and regards,

Thanks a lot Xiaoyi for your feedback! In the geometry it is only one geometry with one fluid inside the box but I am getting the temperature distribution only in the area across the boundaries of source.There is no temperature change deep into the fluid after 10-15 cm. I want that as the initial heat propagation across the boundaries has been done by radiation heat transfer, similarly the rest of heat transfer should be done by conduction and/ or convection deep into the fluid as radiations will not reach deep in to the fluid. Does COMSOL consider it automatically or should I have to incorporate it by myself? If I have to do it by myself, how can I do that, any idea? For the batch processing, I have made the correction in the batch file but still did not get any thing as I am confused about the process. I will write in detail what I did, please correct me if I am wrong? I have two comsol files which I want comsol to run one after the other by using batch processing. I have stored them in D drive. I wrote the lines mentioned in the attached word document and stored it as batch.bat in the C:\COMSOL40a\bin\win32 directory. Then I run this bat file, it opens DOS window with two lines appearing on the screen one after the other as shown in the figure and vanishes after a moment. Then I checked my folde of D drive where I have stored my comsol files but there are no out put files available. Should I make two COMSOL files as output as well? If yes, should they be empty? Please clarify the whole procedure. I will be obliged to you. Thanks and regards,


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 27 oct. 2011, 23:09 UTC−4
Hi,
I don’t know why your batch mode didn’t work. I have tried this function again, and it worked, you can see the attached “picture1”. Now I will write out the steps again (just as an example).
1. create an .mph file, and save this file as E: \myfile\f1.mph
2. open the notepad, that is Start-all program-attachment-notpad, and write the below command:
comsolbatch -inputfile E:\myfile\f1.mph -outputfile E:\myfile\f1out.mph -batchlog E:\myfile\f1out.log
Choose the file types as all files, and save this file as D: \COMSOL42\bin\win32\f123.bat (see attached picture1).
3. double click the file f123.bat to run (see the attached picture1)
4. check the results (see attached picture2)

By the way, for your failure running, I’m not sure whether it has something to do with the windows operation system or the Comsol version. My operation system is windows xp, and the Comsol version is 4.2.

For your first question, actually I don't quite understand what you described. Maybe you can send me your model file if you don't mind.
For your this sentence "Does COMSOL consider it automatically", in my opinion, Comsol is just a software, so it will not consider anything like a human brain, what it will do is what you asked it to do (your settings).



Thanks a lot Xiaoyi for your feedback!

In the geometry it is only one geometry with one fluid inside the box but I am getting the temperature distribution only in the area across the boundaries of source.There is no temperature change deep into the fluid after 10-15 cm. I want that as the initial heat propagation across the boundaries has been done by radiation heat transfer, similarly the rest of heat transfer should be done by conduction and/ or convection deep into the fluid as radiations will not reach deep in to the fluid. Does COMSOL consider it automatically or should I have to incorporate it by myself? If I have to do it by myself, how can I do that, any idea?

For the batch processing, I have made the correction in the batch file but still did not get any thing as I am confused about the process. I will write in detail what I did, please correct me if I am wrong?

I have two comsol files which I want comsol to run one after the other by using batch processing. I have stored them in D drive. I wrote the lines mentioned in the attached word document and stored it as batch.bat in the C:\COMSOL40a\bin\win32 directory.

Then I run this bat file, it opens DOS window with two lines appearing on the screen one after the other as shown in the figure and vanishes after a moment. Then I checked my folde of D drive where I have stored my comsol files but there are no out put files available. Should I make two COMSOL files as output as well? If yes, should they be empty?

Please clarify the whole procedure.

I will be obliged to you.

Thanks and regards,


Hi, I don’t know why your batch mode didn’t work. I have tried this function again, and it worked, you can see the attached “picture1”. Now I will write out the steps again (just as an example). 1. create an .mph file, and save this file as E: \myfile\f1.mph 2. open the notepad, that is Start-all program-attachment-notpad, and write the below command: comsolbatch -inputfile E:\myfile\f1.mph -outputfile E:\myfile\f1out.mph -batchlog E:\myfile\f1out.log Choose the file types as all files, and save this file as D: \COMSOL42\bin\win32\f123.bat (see attached picture1). 3. double click the file f123.bat to run (see the attached picture1) 4. check the results (see attached picture2) By the way, for your failure running, I’m not sure whether it has something to do with the windows operation system or the Comsol version. My operation system is windows xp, and the Comsol version is 4.2. For your first question, actually I don't quite understand what you described. Maybe you can send me your model file if you don't mind. For your this sentence "Does COMSOL consider it automatically", in my opinion, Comsol is just a software, so it will not consider anything like a human brain, what it will do is what you asked it to do (your settings). [QUOTE] Thanks a lot Xiaoyi for your feedback! In the geometry it is only one geometry with one fluid inside the box but I am getting the temperature distribution only in the area across the boundaries of source.There is no temperature change deep into the fluid after 10-15 cm. I want that as the initial heat propagation across the boundaries has been done by radiation heat transfer, similarly the rest of heat transfer should be done by conduction and/ or convection deep into the fluid as radiations will not reach deep in to the fluid. Does COMSOL consider it automatically or should I have to incorporate it by myself? If I have to do it by myself, how can I do that, any idea? For the batch processing, I have made the correction in the batch file but still did not get any thing as I am confused about the process. I will write in detail what I did, please correct me if I am wrong? I have two comsol files which I want comsol to run one after the other by using batch processing. I have stored them in D drive. I wrote the lines mentioned in the attached word document and stored it as batch.bat in the C:\COMSOL40a\bin\win32 directory. Then I run this bat file, it opens DOS window with two lines appearing on the screen one after the other as shown in the figure and vanishes after a moment. Then I checked my folde of D drive where I have stored my comsol files but there are no out put files available. Should I make two COMSOL files as output as well? If yes, should they be empty? Please clarify the whole procedure. I will be obliged to you. Thanks and regards, [/QUOTE]


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28 oct. 2011, 04:10 UTC−4
The problem with your batch file is the space characters in the file names. You have to enclose the file names in quotation marks if they contain spaces, such as: comsolbatch -inputfile "D:\folder name with spaces in it\my model.mph". Otherwise comsolbatch will just see D:\folder for the input file name and quit.
The problem with your batch file is the space characters in the file names. You have to enclose the file names in quotation marks if they contain spaces, such as: comsolbatch -inputfile "D:\folder name with spaces in it\my model.mph". Otherwise comsolbatch will just see D:\folder for the input file name and quit.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28 oct. 2011, 04:27 UTC−4
On a more general note, I use the following batch scripts to run all models contained in the current folder.

Comsol_run_file.cmd
@echo off
echo Starting Comsol simulation "%~n1".
comsolbatch -inputfile "%~n1.mph" -batchlog "%~n1.log" %2 %3 %4 %5 %6 %7 %8 %9


Comsol_run_folder.cmd
@echo off
echo Running all Comsol models in the current folder...
for %%i in (*.mph) do call Comsol_run_file "%%i" %*


This requires that the Comsol binary directory (e.g., C:\Comsol42\bin\win64) be in the Windows search path.

I sometimes use the following batch scripts if I want to run only a subset of files or run them in a particular order:

Comsol_make_queue.cmd
@echo off
echo Creating job queue from .mph files in the current folder, see "queue.txt".
dir *.mph /B /ON >queue.txt
echo You may edit the job queue and then invoke "Comsol_run_queue" to start it.


Comsol_run_queue.cmd
@echo off
echo Running all Comsol models listed in "queue.txt" in the current folder...
for /f "tokens=*" %%i in (queue.txt) do call Comsol_run_file "%%i" %*


All these scripts overwrite the input file. If this behavior is not desired, one could add a parameter such as -outputfile "%~n1_out.mph" to the third line in Comsol_run_file.cmd. Refer to the Windows command line documentation for details on the syntax.
On a more general note, I use the following batch scripts to run all models contained in the current folder. Comsol_run_file.cmd [quote]@echo off echo Starting Comsol simulation "%~n1". comsolbatch -inputfile "%~n1.mph" -batchlog "%~n1.log" %2 %3 %4 %5 %6 %7 %8 %9 [/quote] Comsol_run_folder.cmd [quote]@echo off echo Running all Comsol models in the current folder... for %%i in (*.mph) do call Comsol_run_file "%%i" %* [/quote] This requires that the Comsol binary directory (e.g., C:\Comsol42\bin\win64) be in the Windows search path. I sometimes use the following batch scripts if I want to run only a subset of files or run them in a particular order: Comsol_make_queue.cmd [quote]@echo off echo Creating job queue from .mph files in the current folder, see "queue.txt". dir *.mph /B /ON >queue.txt echo You may edit the job queue and then invoke "Comsol_run_queue" to start it. [/quote] Comsol_run_queue.cmd [quote]@echo off echo Running all Comsol models listed in "queue.txt" in the current folder... for /f "tokens=*" %%i in (queue.txt) do call Comsol_run_file "%%i" %* [/quote] All these scripts overwrite the input file. If this behavior is not desired, one could add a parameter such as -outputfile "%~n1_out.mph" to the third line in Comsol_run_file.cmd. Refer to the Windows command line documentation for details on the syntax.

Muhammad Mohsin Rehman

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30 oct. 2011, 22:49 UTC−4
Thanks Xiaoyi,

Yes your file is working but I do not know why it is not working in my case? Please have a look on the attached word document and rectify me if I am wrong. I am copying and pasting this text into the Notepad file and saving this text document as batch_result.bat in the COMSOL directory win32 folder as you mentioned.

Please find attached my model file as well for your reference and check why heat is not propagating deep into the fluid?

Thanking in anticipation.
Thanks Xiaoyi, Yes your file is working but I do not know why it is not working in my case? Please have a look on the attached word document and rectify me if I am wrong. I am copying and pasting this text into the Notepad file and saving this text document as batch_result.bat in the COMSOL directory win32 folder as you mentioned. Please find attached my model file as well for your reference and check why heat is not propagating deep into the fluid? Thanking in anticipation.


Muhammad Mohsin Rehman

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30 oct. 2011, 22:56 UTC−4

The problem with your batch file is the space characters in the file names. You have to enclose the file names in quotation marks if they contain spaces, such as: comsolbatch -inputfile "D:\folder name with spaces in it\my model.mph". Otherwise comsolbatch will just see D:\folder for the input file name and quit.


Thanks John,

I tried to do the same bu putting the path of file in quotes but when I run the batch file after saving it, it just appeared momentarily and vanished. If I finish the quotes, it stays there for some time showing the following message but nothing starts and it closes after some time(seconds). Please see the attached image for the clear view of what it shows?
Also please find attached the word file, I copied the text in Notepad file and saved it as batch_result.bat in COMSOL directory but did not receive any out put in response on running it except monetary show up.
Can you please suggest some thing else?
[QUOTE] The problem with your batch file is the space characters in the file names. You have to enclose the file names in quotation marks if they contain spaces, such as: comsolbatch -inputfile "D:\folder name with spaces in it\my model.mph". Otherwise comsolbatch will just see D:\folder for the input file name and quit. [/QUOTE] Thanks John, I tried to do the same bu putting the path of file in quotes but when I run the batch file after saving it, it just appeared momentarily and vanished. If I finish the quotes, it stays there for some time showing the following message but nothing starts and it closes after some time(seconds). Please see the attached image for the clear view of what it shows? Also please find attached the word file, I copied the text in Notepad file and saved it as batch_result.bat in COMSOL directory but did not receive any out put in response on running it except monetary show up. Can you please suggest some thing else?


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 31 oct. 2011, 08:04 UTC−4
Hi,
I can give two suggestions, you can try them.
1. Shorten the storing directory of the .mph file, like what I did, maybe it's the problem of the space between the words.
2. I cannot see the .bat file on your screen shot, are you sure you have saved the .bat file where it should be? On my screen shot attached last post, you can see the .bat file which is highlighted by the red arrow.



Thanks Xiaoyi,

Yes your file is working but I do not know why it is not working in my case? Please have a look on the attached word document and rectify me if I am wrong. I am copying and pasting this text into the Notepad file and saving this text document as batch_result.bat in the COMSOL directory win32 folder as you mentioned.

Please find attached my model file as well for your reference and check why heat is not propagating deep into the fluid?

Thanking in anticipation.


Hi, I can give two suggestions, you can try them. 1. Shorten the storing directory of the .mph file, like what I did, maybe it's the problem of the space between the words. 2. I cannot see the .bat file on your screen shot, are you sure you have saved the .bat file where it should be? On my screen shot attached last post, you can see the .bat file which is highlighted by the red arrow. [QUOTE] Thanks Xiaoyi, Yes your file is working but I do not know why it is not working in my case? Please have a look on the attached word document and rectify me if I am wrong. I am copying and pasting this text into the Notepad file and saving this text document as batch_result.bat in the COMSOL directory win32 folder as you mentioned. Please find attached my model file as well for your reference and check why heat is not propagating deep into the fluid? Thanking in anticipation. [/QUOTE]

Muhammad Mohsin Rehman

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 31 oct. 2011, 12:37 UTC−4
Thanks Xiaoyi,

According to your suggestion, I tried to proceed further by saving the .mph locations where there were no spaces in the names of the folders in path. I got cleared from that error but trapped in another error, please look at the attached image. You can also see the .bat file created in the path of COMSOL in C drive.

Can you please give some clues about thus error?

Thanks in advance.
Thanks Xiaoyi, According to your suggestion, I tried to proceed further by saving the .mph locations where there were no spaces in the names of the folders in path. I got cleared from that error but trapped in another error, please look at the attached image. You can also see the .bat file created in the path of COMSOL in C drive. Can you please give some clues about thus error? Thanks in advance.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2 nov. 2011, 07:30 UTC−4
I'm sorry I don't know what's the problem? Maybe you can check the two files server8.log and server9.log according to the error information, or you can ask the Comsol Support for help.




Thanks Xiaoyi,

According to your suggestion, I tried to proceed further by saving the .mph locations where there were no spaces in the names of the folders in path. I got cleared from that error but trapped in another error, please look at the attached image. You can also see the .bat file created in the path of COMSOL in C drive.

Can you please give some clues about thus error?

Thanks in advance.


I'm sorry I don't know what's the problem? Maybe you can check the two files server8.log and server9.log according to the error information, or you can ask the Comsol Support for help. [QUOTE] Thanks Xiaoyi, According to your suggestion, I tried to proceed further by saving the .mph locations where there were no spaces in the names of the folders in path. I got cleared from that error but trapped in another error, please look at the attached image. You can also see the .bat file created in the path of COMSOL in C drive. Can you please give some clues about thus error? Thanks in advance. [/QUOTE]

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 21 nov. 2011, 06:41 UTC−5
Dear all,

I had the same problem (but on linux): I wanted to start one job after another.

First I tried a ordinary queuing system for linux sqs3.1. but this was not working, because the command "comsol" only starts the real job called "comsollauncher". So for the queuing systemthe job comsol seemed finished and it immediately started the next one

I wrote two small scripts for the bash-shell, doing the job

cj_run saves the actual directory and the name of the job to a file in the job directory (Mustbe started in the working directory of the mph file)

cj_daemon is started automatically by the cron daemon every 5 minutes. it looks at the list, checks if there is a running or finished job and starts a new job, if the machine is empty.

So it's not 100%, yet, but seems to work

I guess something similar could be constructed for windows with some batch files as well.
google for cron AND Windows 7
google for windows power shell OR windows script host

Regards

Jan

>>>>>>>>>>>> cj_run file
#!/bin/bash

# RUN-directory (must exist)
VRUN=/home/jan/bin/CJ

# read actual job-Number from file cj_number
(at start enter 100 to be 3 digit number, otherwise sorting is screewed)
read -s -n 3 JNO < $VRUN/cj_number

# determine actual directory
VERZ=$PWD

# Make a run-file in the run directory
# Writing actual directory and job_name to file
echo $VERZ $1 > $VRUN/$JNO\_$1.run

# Increase Job number by 1 and write to file cj_number
JNO1=$(($JNO+1))

echo $JNO1 > $VRUN/cj_number

exit
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

cj_daemon file >>>>>>>>>>>>>>>>>
#!/bin/bash

# directory for the jobs
VCJ=/home/jan/bin/CJ

# change to that directory
cd $VCJ

# look for all run files
for X in *.run ; do


# No run file -> nothing to do -> exit
if [ ! -e $X ] ;then exit ;fi

# read run file VERZ contains directory NAME contains name of mph-file
read VERZ NAME < "$X"

# Check status of coressponding status file

# Read first letter
# R = Running
# D = Done
# E = Error

# check for status file
if [ -e $VERZ/$NAME.status ] ; then

read -s -n 1 VAR < "$VERZ/$NAME.status"

# If it's still running -> nothing to do -> exit
if [ $VAR = 'R' ] ; then exit

else

# Found Done file; move job-file to directory FERTIG (German for ready; directory must exist)
if [ $VAR = 'D' ] ; then mv $X FERTIG ; fi

# Found Errof file; move job-file to directory FERTIG
if [ $VAR = 'E' ] ; then mv $X FERTIG ; fi

fi
fi
done

# From here no running or done or error jobs left, check for new job
for X in *.run ; do

# check if run file exist and read
if [ -e $X ] ; then
read VERZ NAME < "$X"

# change directory where mph-file is
cd $VERZ

# Start mph file
/home/jan/bin/comsol batch -inputfile $NAME -batchlog $NAME.log >/dev/null 2>&1

fi

exit

done
<<<<<<<<<<<<<<<<<<<<<<<

Dear all, I had the same problem (but on linux): I wanted to start one job after another. First I tried a ordinary queuing system for linux sqs3.1. but this was not working, because the command "comsol" only starts the real job called "comsollauncher". So for the queuing systemthe job comsol seemed finished and it immediately started the next one I wrote two small scripts for the bash-shell, doing the job cj_run saves the actual directory and the name of the job to a file in the job directory (Mustbe started in the working directory of the mph file) cj_daemon is started automatically by the cron daemon every 5 minutes. it looks at the list, checks if there is a running or finished job and starts a new job, if the machine is empty. So it's not 100%, yet, but seems to work I guess something similar could be constructed for windows with some batch files as well. google for cron AND Windows 7 google for windows power shell OR windows script host Regards Jan >>>>>>>>>>>> cj_run file #!/bin/bash # RUN-directory (must exist) VRUN=/home/jan/bin/CJ # read actual job-Number from file cj_number (at start enter 100 to be 3 digit number, otherwise sorting is screewed) read -s -n 3 JNO < $VRUN/cj_number # determine actual directory VERZ=$PWD # Make a run-file in the run directory # Writing actual directory and job_name to file echo $VERZ $1 > $VRUN/$JNO\_$1.run # Increase Job number by 1 and write to file cj_number JNO1=$(($JNO+1)) echo $JNO1 > $VRUN/cj_number exit

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 20 sept. 2013, 01:34 UTC−4
I know that this is a late post, but I read this thread recently,

www.comsol.com/community/forums/general/thread/2357/

And thought that maybe you could try using advice from this line:

"One think I want to mention is, that I work with Windows and there one
need to add also the command -psave on. Otherwise no data will be stored."

I am still familiarizing myself with parametric and batch mode, but this seems to possibly be a solution.

Charlie
I know that this is a late post, but I read this thread recently, http://www.comsol.com/community/forums/general/thread/2357/ And thought that maybe you could try using advice from this line: "One think I want to mention is, that I work with Windows and there one need to add also the command -psave on. Otherwise no data will be stored." I am still familiarizing myself with parametric and batch mode, but this seems to possibly be a solution. Charlie

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 oct. 2014, 03:42 UTC−4
Hi,
I am working with comsol in Linux. I used the psave on. But the command interface said that it was unknown argument.

So for comsol batch modal in linux what should I do so save data?

Thx
Hi, I am working with comsol in Linux. I used the psave on. But the command interface said that it was unknown argument. So for comsol batch modal in linux what should I do so save data? Thx

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27 févr. 2016, 16:24 UTC−5
To follow up on the earlier post from Xiaoyi Yu

If you have two .mph files (f1.mph, f2.mph) stored under E:\myfolder
you can do like this:

open the notepad, and input the command lines below:

path=%path%;C:\Program Files\COMSOL\COMSOL52\Multiphysics\bin\win64
comsolbatch -inputfile E:\myfolder\f1.mph -outputfile E:\myfolder\f1out.mph -batchlog E:\myfolder\f1out.log
comsolbatch -inputfile E:\myfolder\f2.mph -outputfile E:\myfolder\f2out.mph -batchlog E:\myfolder\f2out.log

store the file as f123.bat (for example)

If you include the path command as the first line of the batch file, you don't need to put the batch file actually in the COMSOL installation directory.

You could put the batch file on your desktop and when you double click on the .bat file, the batch file will run as you expect.

-DW
To follow up on the earlier post from Xiaoyi Yu If you have two .mph files (f1.mph, f2.mph) stored under E:\myfolder you can do like this: open the notepad, and input the command lines below: path=%path%;C:\Program Files\COMSOL\COMSOL52\Multiphysics\bin\win64 comsolbatch -inputfile E:\myfolder\f1.mph -outputfile E:\myfolder\f1out.mph -batchlog E:\myfolder\f1out.log comsolbatch -inputfile E:\myfolder\f2.mph -outputfile E:\myfolder\f2out.mph -batchlog E:\myfolder\f2out.log store the file as f123.bat (for example) If you include the path command as the first line of the batch file, you don't need to put the batch file actually in the COMSOL installation directory. You could put the batch file on your desktop and when you double click on the .bat file, the batch file will run as you expect. -DW

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 24 avr. 2016, 20:18 UTC−4
DW:

I used the command below. It can generate the f1out.mph but with no results stored init. How to start "Compute"? or if you have two Studies, how to instruct Comsol to compute either the 1st or 2nd study? Thanks.

path=%path%;C:\Program Files\COMSOL\COMSOL43\Multiphysics\bin\win64
comsolbatch -inputfile f1.mph -outputfile f1out.mph -batchlog f1out.log
comsolbatch -inputfile f2.mph -outputfile f2out.mph -batchlog f2out.log
DW: I used the command below. It can generate the f1out.mph but with no results stored init. How to start "Compute"? or if you have two Studies, how to instruct Comsol to compute either the 1st or 2nd study? Thanks. path=%path%;C:\Program Files\COMSOL\COMSOL43\Multiphysics\bin\win64 comsolbatch -inputfile f1.mph -outputfile f1out.mph -batchlog f1out.log comsolbatch -inputfile f2.mph -outputfile f2out.mph -batchlog f2out.log

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 30 juin 2016, 09:12 UTC−4
Hello, I was also asking the same questions. This post helps

www.comsol.com/community/forums/general/thread/31918/

as well as running comsolbatch --help from the command line (see screenshot)
Hello, I was also asking the same questions. This post helps https://www.comsol.com/community/forums/general/thread/31918/ as well as running comsolbatch --help from the command line (see screenshot)


Please login with a confirmed email address before reporting spam

Posted: 7 years ago 22 août 2017, 04:24 UTC−4
This is an Interesting thread.

Let's imagine that I have created a Job within the .MPH file which performs the following operations :

- meshing of the model
- solving
- save on a "temp" file
- Post-processing
- export

How can I launch multiple .mph files from a batch file, and specify to perform the "JOB" sequence included in each of them ?

The solving is time-consuming, but even postprocessing can take long time, and it would be interesting to automatize this phase as well.

Any hints, on how to proceed ?
This is an Interesting thread. Let's imagine that I have created a Job within the .MPH file which performs the following operations : - meshing of the model - solving - save on a "temp" file - Post-processing - export How can I launch multiple .mph files from a batch file, and specify to perform the "JOB" sequence included in each of them ? The solving is time-consuming, but even postprocessing can take long time, and it would be interesting to automatize this phase as well. Any hints, on how to proceed ?

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.