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.

Non uniform array spacing

Please login with a confirmed email address before reporting spam

Hello, I currently have a uniformly spaced array of 2d rectangles. I would like to instead create an array where the distances between rectangles varies according to some polynomial function based on the x coordinate corresponding to the rectangle's location.

I have been able to achieve this manually by creating many individual rectangles and creating a parameter for each rectangle's x location, but I am curious if there is an easier way to do this, particularly one that will allow me to more easily change the number of rectangles in the array.

Thanks!


3 Replies Last Post 19 déc. 2023, 00:48 UTC−5
Daniel Bertilsson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 12 months ago 5 déc. 2023, 04:57 UTC−5

To get a non-uniform spacing, you can use a Move feature instead of Array. In the x displacement text field, enter for example f({range(0,1,10)}), where f is a function, for example {range(0,1,10)}^2+{range(0,1,10)}. Then use a second Move feature to move the resulting moved objects in the y-direction.

To get a non-uniform spacing, you can use a Move feature instead of Array. In the x displacement text field, enter for example f({range(0,1,10)}), where f is a function, for example {range(0,1,10)}^2+{range(0,1,10)}. Then use a second Move feature to move the resulting moved objects in the y-direction.

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 12 months ago 5 déc. 2023, 16:07 UTC−5
Updated: 12 months ago 5 déc. 2023, 16:13 UTC−5

Hi Ilan,

For completeness sake, and although it is probably overkill for your needs, I'll mention that you could also use a model method to create your geometry. See this blog post for an example.

A couple of other approaches would consist in using MATLAB and LiveLink for MATLAB (assuming your COMSOL license includes it), or the COMSOL Java API.

But Daniel's approach is by far the simplest one so there's no reason for you to look further if it works for you.

Best regards,

Jeff

-------------------
Jeff Hiller
Hi Ilan, For completeness sake, and although it is probably overkill for your needs, I'll mention that you could also use a model method to create your geometry. See [this blog post](https://www.comsol.com/blogs/how-to-create-a-randomized-geometry-using-model-methods/) for an example. A couple of other approaches would consist in using MATLAB and LiveLink for MATLAB (assuming your COMSOL license includes it), or the COMSOL Java API. But Daniel's approach is by far the simplest one so there's no reason for you to look further if it works for you. Best regards, Jeff

Please login with a confirmed email address before reporting spam

Posted: 11 months ago 19 déc. 2023, 00:48 UTC−5
Updated: 11 months ago 19 déc. 2023, 00:48 UTC−5

Thank you both for your responses! I ended up needing MATLAB with LiveLink for a different purpose, so this was an easy problem to start learning it with.

Thank you both for your responses! I ended up needing MATLAB with LiveLink for a different purpose, so this was an easy problem to start learning it with.

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.