Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tidy3d/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def old_json_sources(sim: Simulation) -> List[Dict]:
}
elif isinstance(source, ModeSource):
mode_ind = source.mode.mode_index
num_modes = source.mode.num_modes if source.mode.num_modes else mode_ind + 1
direction = "forward" if source.direction == "+" else "backward"
src = {
"name": name,
Expand All @@ -263,7 +264,7 @@ def old_json_sources(sim: Simulation) -> List[Dict]:
"amplitude": source.source_time.amplitude,
"mode_ind": mode_ind,
"target_neff": source.mode.target_neff,
"Nmodes": source.mode.num_modes,
"Nmodes": num_modes,
}
elif isinstance(source, PlaneWave):
normal_index = [s == 0 for s in source.size].index(True)
Expand Down
14 changes: 10 additions & 4 deletions tidy3d/plugins/mode/mode_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,19 @@ def solve(self, mode: Mode) -> ModeInfo:
Object containing mode profile and effective index data.
"""

normal_axis = self.plane.size.index(0.0)

# note discretizing, need to make consistent
eps_xx = np.squeeze(self.simulation.epsilon(self.plane, "Ex", self.freq).values)
eps_yy = np.squeeze(self.simulation.epsilon(self.plane, "Ey", self.freq).values)
eps_zz = np.squeeze(self.simulation.epsilon(self.plane, "Ez", self.freq).values)
eps_xx = self.simulation.epsilon(self.plane, "Ex", self.freq)
eps_yy = self.simulation.epsilon(self.plane, "Ey", self.freq)
eps_zz = self.simulation.epsilon(self.plane, "Ez", self.freq)

# make numpy array and get rid of normal axis
eps_xx = np.squeeze(eps_xx.values, axis=normal_axis)
eps_yy = np.squeeze(eps_yy.values, axis=normal_axis)
eps_zz = np.squeeze(eps_zz.values, axis=normal_axis)

# swap axes to waveguide coordinates (propagating in z)
normal_axis = self.plane.size.index(0.0)
eps_wg_zz, (eps_wg_xx, eps_wg_yy) = self.plane.pop_axis(
(eps_xx, eps_yy, eps_zz), axis=normal_axis
)
Expand Down
16 changes: 8 additions & 8 deletions tidy3d/web/webapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def download(task_id: TaskId, simulation: Simulation, path: str = "simulation_da
mon_file = os.path.join(directory, "monitor_data.hdf5")
log_file = os.path.join(directory, "tidy3d.log")

log.info("clearing existing files before downloading")
log.debug("clearing existing files before downloading")
for _path in (sim_file, mon_file, path):
_rm_file(_path)

Expand All @@ -241,17 +241,17 @@ def download(task_id: TaskId, simulation: Simulation, path: str = "simulation_da
_download_file(task_id, fname="monitor_data.hdf5", path=mon_file)

# TODO: do this stuff server-side
log.info("getting log string")
log.debug("getting log string")
_download_file(task_id, fname="tidy3d.log", path=log_file)
with open(log_file, "r", encoding="utf-8") as f:
log_string = f.read()

log.info("loading old monitor data to data dict")
log.debug("loading old monitor data to data dict")
# TODO: we cant convert old simulation file to new, so we'll ask for original as input instead.
# simulation = Simulation.load(sim_file)
mon_data_dict = load_old_monitor_data(simulation=simulation, data_file=mon_file)

log.info("creating SimulationData from monitor data dict")
log.debug("creating SimulationData from monitor data dict")
sim_data = load_solver_results(
simulation=simulation,
solver_data_dict=mon_data_dict,
Expand All @@ -261,7 +261,7 @@ def download(task_id: TaskId, simulation: Simulation, path: str = "simulation_da
log.info(f"exporting SimulationData to {path}")
sim_data.export(path)

log.info("clearing extraneous files")
log.debug("clearing extraneous files")
_rm_file(sim_file)
_rm_file(mon_file)
_rm_file(log_file)
Expand Down Expand Up @@ -343,7 +343,7 @@ def _upload_task( # pylint:disable=too-many-locals

method = os.path.join("fdtd/model", folder_name, "task")

log.info("Creating task.")
log.debug("Creating task.")
try:
task = http.post(method=method, data=data)
task_id = task["taskId"]
Expand All @@ -352,7 +352,7 @@ def _upload_task( # pylint:disable=too-many-locals
raise WebError(error_json["error"]) from e

# upload the file to s3
log.info("Uploading the json file")
log.debug("Uploading the json file")

client, bucket, user_id = get_s3_user()

Expand Down Expand Up @@ -416,5 +416,5 @@ def _download_file(task_id: TaskId, fname: str, path: str) -> None:
def _rm_file(path: str):
"""Clear path if it exists."""
if os.path.exists(path) and not os.path.isdir(path):
log.info(f"removing file {path}")
log.debug(f"removing file {path}")
os.remove(path)