Please login with a confirmed email address before reporting spam
Posted:
6 years ago
25 mai 2019, 06:46 UTC−4
Updated:
6 years ago
25 mai 2019, 07:07 UTC−4
Hi Manula,
Have a look at the withsol
and setval
operators. By using them in the Initial conditions entry of your physics, you might be able to get what you want.
Another option which will give you far more control is to save your model as a java program and modify it to include a loop over your settings. Here are the steps for doing that:
- Compact the model's history (
File > Compact History
)
- Save your model as a java file (
File > Save As > Model File for Java
)
- Open the newly created java file with a text editor, or ideally with Eclipse, if you have that installed. This contains all the instructions to create your model
- Use the tags to navigate the file. You can look at the tags of the nodes of your model builder, by clicking the arrow at the top of the model builder window and ticking the "Tag" checkbox.
- Figure out which lines correspond to the settings you performed manually. To get help with that go in the graphical interface to the node you modified. Do a right click and select
Copy as code to clipboard > Create
and Copy as code to clipboard > Set All
. Paste this into a text editor to see the corresponding java code. You can then search for these lines in your main java file.
- Add a loop to apply these settings repeatedly. You may or may not want to comment out all the
.run()
calls, which actually run computations.
- Once you are happy with your changes, save the java and compile it by running
comsol compile name_of_your_file.java
If all goes well this will create name_of_your_file.class
- Run the model by calling
comsol batch -inputfile name_of_your_file.class
. It will trigger calculations if a .run()
method is present in your java. At the end, the model will be saved to name_of_your_file.mph
- Open the resulting mph in the graphical interface and check that the settings are what you intended.
- For more information see the programming reference manual
I know it looks like a lot, but once you get the hang of it, this is very easy and will allow you to automate anything you used to do manually with COMSOL.
Hi Manula,
Have a look at the `withsol` and `setval` operators. By using them in the **Initial conditions** entry of your physics, you might be able to get what you want.
Another option which will give you far more control is to save your model as a java program and modify it to include a loop over your settings. Here are the steps for doing that:
1. Compact the model's history (`File > Compact History`)
2. Save your model as a java file (`File > Save As > Model File for Java`)
3. Open the newly created java file with a text editor, or ideally with Eclipse, if you have that installed. This contains all the instructions to create your model
4. Use the tags to navigate the file. You can look at the tags of the nodes of your model builder, by clicking the arrow at the top of the model builder window and ticking the "Tag" checkbox. ![see_tag](https://i.ibb.co/MkRJ780/see-tag.png)
6. Figure out which lines correspond to the settings you performed manually. To get help with that go in the graphical interface to the node you modified. Do a right click and select `Copy as code to clipboard > Create` and `Copy as code to clipboard > Set All`. Paste this into a text editor to see the corresponding java code. You can then search for these lines in your main java file. ![copy_code](https://i.ibb.co/thm4p4r/copy-code-to-clipboard.png)
7. Add a loop to apply these settings repeatedly. You may or may not want to comment out all the `.run()` calls, which actually run computations.
8. Once you are happy with your changes, save the java and compile it by running `comsol compile name_of_your_file.java` If all goes well this will create `name_of_your_file.class`
9. Run the model by calling `comsol batch -inputfile name_of_your_file.class`. It will trigger calculations if a `.run()` method is present in your java. At the end, the model will be saved to `name_of_your_file.mph`
10. Open the resulting mph in the graphical interface and check that the settings are what you intended.
11. For more information see the programming reference manual
I know it looks like a lot, but once you get the hang of it, this is very easy and will allow you to automate anything you used to do manually with COMSOL.