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 duplicate models efficiently

Please login with a confirmed email address before reporting spam

Hello, I am new to using COMSOL Multiphysics and Livelink and I was wondering if there are any time efficient way to create a series of duplicated models in geometry.

I would like to find a way to create a shape in 3D and then duplicate that shape an arbitrary number of times with some predictable difference in position between each object. Of course, I know that I can right click a geometry under the model-building, duplicate, and then change the position of the duplication. However, this process quickly becomes tedious after 3-4 duplications.

Ideally there would be some way to create these duplications using a for-loop in Livelink.


2 Replies Last Post 23.04.2019, 06:30 GMT-4
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 12.04.2019, 17:24 GMT-4
Updated: 5 years ago 12.04.2019, 17:24 GMT-4

Hello Owen,

Yes, you can use LiveLink for MATLAB to automate geometry creation, if you have MATLAB, see its documentation for syntax information.

Another approach is to use model methods, see this webinar for example or this blog.

And if you just want to generate equally spaced copies of an object, in the GUI you can use the array tool.

Best,

Jeff

-------------------
Jeff Hiller
Hello Owen, Yes, you can use LiveLink for MATLAB to automate geometry creation, if you have MATLAB, see its documentation for syntax information. Another approach is to use model methods, see this [webinar](https://www.comsol.com/video/automating-your-modeling-workflow-with-model-methods-in-comsol) for example or this [blog](https://www.comsol.com/blogs/how-to-create-a-randomized-geometry-using-model-methods/). And if you just want to generate equally spaced copies of an object, in the GUI you can use the array tool. Best, Jeff

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 23.04.2019, 06:30 GMT-4

The rule is simple. If you know how to do a thing in the Comsol GUI then you can learn about the corresponding syntax by saving the model as an M-file.

Try to add something (e.g. a box) to your model. Duplicate it. Change a few parameters for the new box. Save the model as an M-file. If you open the M-file you can see exactly what commands to use in your Matlab scripts.

There is a duplicate() method in the API that can be used for duplication. It is not expected that duplication is faster than creating a new object from scratch (but it may be possible to do what you want with less coding).

-------------------
Lars Gregersen
Comsol Denmark
The rule is simple. If you know how to do a thing in the Comsol GUI then you can learn about the corresponding syntax by saving the model as an M-file. Try to add something (e.g. a box) to your model. Duplicate it. Change a few parameters for the new box. Save the model as an M-file. If you open the M-file you can see exactly what commands to use in your Matlab scripts. There is a duplicate() method in the API that can be used for duplication. It is not expected that duplication is faster than creating a new object from scratch (but it may be possible to do what you want with less coding).

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.