June 5, 2023 at 8:12 pmColorSubscriber
I have 144 variables that are numbered like a 12*12 matrix, i.e., z_1_1, z_1_12, z_12_1, z_12_12, and each of these variables have a number as their value, say z_12_10=0.9. I want to now put these variables in a matrix with the same format. So, element (1,1) of the matrix is z_1_1 while element (5,5) is z_5_5. So I use two for loops that sweep over the 12 elements along each direction and try to attribiute each variable to an element. But that seems to not work, because I am using something like this:
The softare does not like this type of attribute. It seems that it is OK to have str2num("2") but if instead we have str2num("z_1_1), it does not work even though that will be a avariable with a number.
Can you please help me figure this out?
June 6, 2023 at 6:08 pmGuilin SunAnsys Employee
Zmatrix is a numerical matrix which cannot hold strings.
Your script is to covert "z_ii_jj" to numerical, but its numeric of "z_ii_jj".
I am not sure why you assign one single value to one single variable.
If your intention is to hold the string z_ii_jj, you can use "struct" : struct - Script command – Ansys Optics
June 6, 2023 at 7:33 pmColorSubscriber
The intention is to optimize all these parameters, using an optimizer. It is a 12*12 matrix and each element of the matrix is used as an x position for a rectangle in the GUI model. When I create the two for loops, I can sweep over these positions easily and assign the x position of the rectangles. But the problem is that these are defined as numeric variables and I cannot sweep over them by any means right now. So, I would have to manually create the matrix and then sweep over all variables which is extremely time-inefficient. So, I am looking for a way to do this properly.
June 8, 2023 at 5:07 pmGuilin SunAnsys Employee
It is not very clear for me: you use 12by12 matrix to describe the x position of a rectangle, and want to sweep the value? or want to assign the x position by the matrix value from the 12 by 12 matix? you can index the matrix, and change the matrix value.
eg, to change the matrix value, Zmatrix(ii,jj)=3, or any other values;
to index the location of Zmatrix, it is the same thing: ii and jj are the indecies. Of course you should have values for the Zmatrix beforehand, or you can assign new value to it.
" When I create the two for loops, I can sweep over these positions easily and assign the x position of the rectangles"
Suppose you have already specified the x positions in the Zmatrix. that is, each value in the Zmatrix elements is the x position. then next you want to change the position of the rectangle, you can
If this is not you want, please draw a diagram and elabrate more.
June 9, 2023 at 5:28 pmColorSubscriber
What I mean is that I have a 12*12 matrix that carries the positions of the elements and I want to optimize these positions. But the optimizer in Lumerical does not optimize a matrix, it only optimizes single values not matrices. So, I am forced to instead define 12*12=144 variables to be able to do my optimization. But now, I have 144 variables and so I have to manually assign them to my elements. I cannot do it in a more automated way, like a for loop. That is why I am trying to do all this str2num etc to make it possible to do this assignment in a more automated way.
June 9, 2023 at 9:19 pmGuilin SunAnsys Employee
If the 12*12 position data is related to 12*12 elements/geometries, then each element has one such value in its geometry settings. You can directly optimize them;
If this 12*12 position data is to form a geometry, such as a polygon, then you will first need to define such polygon with parameteried location. each pair of a coordinate must be a variable and included in the vetex matrix.eg
vtx(i,j)=Zij; where Zij is the numerical locaiton.
Anyway, the 12*12 values are associated with the element positions and they should be defined as variables in order to sweep or optimize.
- You must be logged in to reply to this topic.
Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.
Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- “Import optical generation” or “delta generation rate”?
- Why am I getting “process exited without calling finalize”, and how do I fix it?
- Using a license file on a new license server
- Ansys Insight: Diverging Simulations
- Error: addfdtd is not a valid function or a variable name
- Questions about the calculation of the cross-polarization conversion efficiency of metasurface
- Error on Lumerical device
- Ansys Insight: About override mesh in FDTD: its use and settings
- Finding your Ansys (or Lumerical) account number
- Lumerical – error message when trying to open from Linux terminal
© 2023 Copyright ANSYS, Inc. All rights reserved.