Tagged: export-data, script
-
-
December 13, 2022 at 10:34 am
Matthias Sauter
SubscriberHey,
I've got a question regarding the exporting and importing of a mode in FDTD .
So I basically used the script from this site https://optics.ansys.com/hc/en-us/articles/360034383034-Using-monitor-data-to-define-the-spatial-field-profile-of-a-source-in-FDTD and adapted it for my problem.
The issue is, that I want to export/import only one wavelength and its mode with a script, not the modes of the other wavelengths. So if you look at the screenshot, I only want to export the mode with index 65 at ~922.7 nm and NOT all the other modes (all the other indices).
Is there a good way for that?
Here's the code I'm using at the moment:
#########################################################
# file: usr_source_from_monitor.lsf
#
# Description:
# This script runs simulation 1, extracts field data
# from the transmission monitor, then uses that data
# as a source in simulation 2.
#
# Copyright 2009, Lumerical Solutions, Inc.
####################################################################################################
# Run initial simulation. Result from this simulation will
# be used as the source for the second simulation.
# load and run initial file
# image the electric field over the whole taper, and at the output transmission monitor
#visualize(getresult("monitors::zp","E"));
#visualize(getresult("monitors::mode","E"));# calculate the power transmission
#T_sim1 = getresult("zp","T");
#?"Transmission from simulation 1: " +num2str(T_sim1.T);
###########################################
# get the E & H fields to use as a source for the
# 2nd simulation# get the field data
E_field=getresult("monitors::zp","E");
H_field=getresult("monitors::zp","H");
# To use E&H data in the import source, the E & H fields
# must be contained in a single dataset
# Alternately, if only using E field data, then the 'E_field' dataset
EM = rectilineardataset("EM fields",E_field.x,E_field.y,E_field.z);
#rectilineardataset can be directly loaded into the Import source.
EM.addparameter("lambda",c/E_field.f,"f",E_field.f); # Note: Import source can only load datasets with one frequency point of data.
EM.addattribute("E",E_field.Ex,E_field.Ey,E_field.Ez);
EM.addattribute("H",H_field.Hx,H_field.Hy,H_field.Hz);
###########################################
# load the 2nd simulation
load("SMF_Into_HCF_180umLANG.fsp");
# if not already run, load the monitor data from
# simulation 1 into the source of simulation 2
if (!havedata("T","x")) {
select("source_1");
importdataset(EM);run;
}
# plot the amount of power absorbed by the particle.
# Notice that results are normalized by the power transmission
# from simulation 1.
Pabs = getresult("trans_box","T");
plot(Pabs.lambda*1e9,-Pabs.T*T_sim1.T,"wavelength (nm)","Absorption","Absorption vs wavelength");
# plot the transmission and reflection vs wavelength
T_sim2=getresult("T","T");
R_sim2=getresult("R","T");plot(c/T_sim2.f*1e9,-T_sim1.T*R_sim2.T,T_sim1.T*T_sim2.T,"wavelength (nm)","R and T","R and T vs wavelength");
legend("R","T"); -
December 13, 2022 at 5:39 pm
Guilin Sun
Ansys EmployeeThe frequency-domain monitor records data for any specified wavelength. The data is a mixture of all modes that were excited during the propagation. So the monitor is not a good way to get the single mode data.
To get data for a specific mode, you can directly use a mode source to do the simulation, without importing and exporting. You can also set the mode source to be broadband.
I am not sure your purpose. If you just want to know the mode profile, you can also use a mode expansion monitor on the waveguide to get the mode properties.
-
December 14, 2022 at 9:31 am
Matthias Sauter
SubscriberThanks for your answer!
Maybe I have to go a little bit more into detail:
I’m simulating a structure, which needs a lot of time and RAM to be simulated. It has many mirrors in 1D so that the light can only go out in one direction (image below, mirrors = DBRs). Here the light after a few back and forth reflections can only go out on the top of the structure, simply said that’s because there are fewer mirrors on top than on bottom and so the probability for the light is higher to go out to the top. This only works for one specific wavelength, which can be seen in the Visualizer 1 in my first post (this visualizer is after the structure, so after all the mirrors). After this mirrored structure I want the light, which coupled out (Visualizer 1), to go into a fiber.
So what I want to do is, take the data from Visualizer 1 (which are obviously already data out of a simulation) and import it as my new source into my fiber simulation.
Obviously, I could also simulate both in one big simulation, but my RAM is unfortunately not sufficient for that.
I hope that clears up some uncertainties.
-
December 14, 2022 at 5:06 pm
Guilin Sun
Ansys EmployeeSO this is a VCSEL, please refer this Photonic Crystal VCSEL simulations.
The radiation mode is formed thorugh diffraction with multi-reflections, the same as the regular FP laser. So you can either simulate the whole device with a monitor outside the cavity, or using the mode inside the cavity to approximate it (but the mode is inside the material, not in the air. they are different). You can also use a Gaussian beam approximation. Please consider which method is "better" for you.
-
December 15, 2022 at 9:41 am
Matthias Sauter
SubscriberIt's not a VCSEL, but comparable, the structure I am using is a micropillar.
And like I said, the micropillar is already simulated, everything worked there. The only thing I want to do now is, export the E and the H field of the simulation. But only at one certain wavelength/index value (the monitor I am using is outside the micropillar). And after exporting it, I would like to import it in another file, but I already achieved this (but only for all wavelengths that got monitored).
I tried to export it via the Matlab export option, but unfortunately this didn't work, due to my Matlab version not being supported by Lumerical2022. That's why I tried to export the data with a script, like I described before. But my code just exported and imported the monitored data for all wavelengths, and not just for one. Do you know a way to export only one wavelength/index?
The image shows the imported data in the new file. Is there maybe a way to filter only wavelength there?
-
December 15, 2022 at 4:53 pm
Guilin Sun
Ansys EmployeeI am not sure where exactly the monitor is located. As mentioned previously, moniotors give total fields. If you think it is ok, you can use the example file to get the result and save it to matlab data file, and then import it. Do you have difficulty in using the script file?
If the monitor is on a waveguide and you think this waveguide mode is the result you want, you can use an mode expansion monitor to get its mode profile, and the S parameter or a or b coefficient, and modify the mode amplitude.
If the matlab version is not supported, then there is nothing we can do right now to use it. But you may try zbf data format.
If the mode profile is what you want with a correction of the amplitude, you can directly use a mode source for second simulation, and use transmission data to get normalized result. As you know, T=transmitted_power/source_power; each simulation has its own source power.eg
T1=transmitted_power_1/source_power_1;
T2=transmitted_power_2/source_power_2;
So you can do like this:
T_total=T2*source_power_2/source_power_1;
I hope this helps.
-
- You must be logged in to reply to this topic.

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.

Ansys Blog
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?
- Error on Lumerical device
- Using a license file on a new license server
- Error: addfdtd is not a valid function or a variable name
- Ansys Insight: Diverging Simulations
- Ansys Insight: Transmission results greater than one
- Ansys Insight: About override mesh in FDTD: its use and settings
- Ansys Insight: Convergence issues in CHARGE
- Is there a Lumerical script command to output the Simulation and Memory requirements?
-
2532
-
2066
-
1285
-
1104
-
459
© 2023 Copyright ANSYS, Inc. All rights reserved.