# Expansion monitor, construction group, both fundamental modes

#1

I have an analysis and in that analysis group I have a construction group.
In this construction group I add an expansion monitor.

What I want to do is instead of selecting just the TM or TE mode, I want to select both by using the user select option and then select the first 2 modes.
However I want to add this in the construction group.

Nonetheless using the way it’s described on the site won’t work for me in the construction group. See the code below, note that a bunch of the parameters are variables in my construction group. The problem here is the updatemodes function as it gives me an error. However if I run the file like this it gives me a random mode, does anyone know how to solve this?

#add expansion monitors
set("name","mode_expansion");
# set the field monitor to be used by the expansion monitor
select("mode_expansion");
setexpansion("output", "x2");
# set the expansion monitor mode solver properties
set("mode selection","user select");  # use the 'user select' option
seteigensolver("use max index",0);
#updatemodes(1:2);
set("x",x_span/2);
set("y",disp_y);
set("z",WG_H-pore_D/2);
set("y span",y_span);
set("z span",z_span);
set("frequency points",nfp);


Analysis groups, contruction and expansion monitor
Analysis groups, contruction and expansion monitor
#3

I’ve been trying for over a day to solve the issue I have been having.

I need to do a sweep over a large number of points, so that means I need to have a large number of different files 120+.
I have an analysis group to do create my structures and to do a number of analysis calculations.

I am using an expansion monitor to do some calculations, and this expansion monitor should be in my analysis group.
The expansions monitor only needs to be calculate it’s modes once (yes this is correct for my setup).
However if it’s in a construction group it needs to be constantly updated, this consumes a lot of time.
My simulations take only about 1-3 minutes each per file, however calculating the modes takes 1+ minutes. Thus drastically increasing my simulation time while it only needs to be once in practice.

Now I’ve tried a few things, updating the modes from a script, but as soon as I change parameters in my construction(analysis) group it creates a new monitor.
So I thought creating a monitor outside the analysis group would work.
What I did was deselect the construction tick mark and but leave the deleteall command.
Then I use a script to move it in the group by using addtogroup, however as soon as I do that, for some ridiculous reason the analysis group updates itself and thus deletes the monitor.
However if I do this manually with “move out of group”, “move up”, “move into group” it does work. However I haven’t been able to find these commands as a script command.

Now, there aren’t any unselect, deselect or invert selection function for scripting, so you can not select all items except one.

So what I tried was making all my structures in the analysis group and then adding those to a sub-group.
While having removed the deleteall function. That way I can selectively remove the sub-group by selecting it and deleting it (this works).
However I need to copy the monitor once it’s moved in the sub-group, back up to main analysis group. (so it won’t get deleted)
In scripts I can use the copytoclipboard function and pasterfromclipboard, however apparently these are not valid functions in an analysis group for some reason.
So there’s still no way for me to preserve a monitor which has already calculated it’s mode and move it out of the sub-group I’m constantly deleting.

This is related to an earlier post, which I solved by updating the modes from the script window, but again shoiw that for some reason that some scripting function are not supported in construction (analysis) groups.

If anyone could help me with this I would be really gratefull.

#4

Dear @Bob_Leuven,

Sorry for the long wait. If I understood correctly the requirements for you application are the following (please let me know if I missed anything):

1. You want an analysis group with a mode expansion monitor inside.
2. You need to select two modes for the mode expansion. Therefore, you need the “user select” option and the updatemodes script function to select those modes.
3. The analysis group creates both the structure and performs the analysis.
4. The mode calculation for the analysis should be done once.
5. You have a sweep over multiple configurations, for all the configurations the mode used for the analysis is the same.

Regarding 2:

As you have found already, the updatemodes script function doesn’t work inside analysis scripts. You have to use it in a regular script (in the script prompt or in the script editor).

Regarding 1 and 3:

Is it necessary to have the mode expansion monitor inside the analysis group? Does the analysis script for that group require the results from the mode expansion? If this is not the case, then I would suggest having the monitor outside the analysis group.

You mentioned that you also create some structures inside the analysis group. In most cases, it is more convenient to have separate groups for structure creation and analysis; for instance, you can use a structure group for the objects that form the structure and a separate analysis group with monitors.

Regarding 4 and 5:

The mode calculation at the mode expansion monitor is triggered only when visualizing the mode profiles or when doing the mode expansion after the simulation. Therefore, if you run a bunch of simulation files, you should see the mode being calculated only at the analysis stage, i.e. after the FDTD simulations.

When you have multiple files and need to do the mode expansion for all of them, the modes will be calculated for each file. As you pointed out this is not efficient if the mode used for the analysis is the same for all the files. However, the software doesn’t have a way to know this in advance so it will treat each file separately.

If the whole process of the mode calculation for all the files is taking a long time, it could be possible to do the mode expansion as a post-processing step using the script function expand. In this approach, you would calculate the mode only once and do the expansion using the fields from each simulation file. This approach is not as straight-forward as the regular mode expansion calculation, so before trying it I have another suggestion. In the Resources configuration you can change the number of threads used in the design environment and see if there is any speed up in the mode calculation; it is possible that your current setup is not optimal.

Hope this makes sense. If you share your simulation file and scripts, I can also take a look and make more specific suggestions. It will be easier to fully understand your problem if I can see the files directly.

#5

correct, doing that now, but still updating for every file after simulation.

The reason I’m creating the monitor and all my structures inside the analysis group because then I can use the same variables for them from the analysis group. This makes it easy for me to make sure everything is aligned properly and that I don’t have to worry about updating/changing all the variables at multiple places.

I tried moving the monitor out but then my analysis group couldn’t get the data from the monitor, this might be because I didn’t know how to do it, but I tried quite a few things.

This is very usefull, I’ll look into how to do this, using the expand function.
I think that might be the best solution for me.
I’m already using a server for simulations with 64 threads of which I use 55 when running the simulations. The reason being is that when using ~61-64 the server tends to clog up and slows down significantly, so I’m leaving myself some wiggle room to make that doesn’t happen.

I’ll send you the files in private message.

#6

Hi @Bob_Leuven,