How do I run a parameter sweep?

How do I run a parameter sweep?#

Date

Category

2023-12-04 18:41:54

Parameter Sweep

To submit multiple simulations and run them concurrently in the server, you can create a tidy3d.web.Batch object including all the simulations you want to run. Then, use tidy3d.web.Batch.run() to upload, run, and get the simulations results in a tidy3d.web.BatchData object. For example:


# Create a dictionary including all the simulations.
sims = {"sim_1": sim_1, "sim_2": sim_2, "sim_3": sim_3}

# Build a Batch object.
batch = tidy3d.web.Batch(simulations=sims, verbose=True)

# Run all the simulations and get the results.
batch_results = batch.run(path_dir="data")

Alternatively, you can use the tidy3d.web.run_async, which submits and runs multiple simulations using only one command.


# Create a dictionary including all the simulations.
sims = {"sim_1": sim_1, "sim_2": sim_2, "sim_3": sim_3}

# Run all the simulations and get the results.
batch_results = batch.run_async(sims, path_dir="data")

After running the simulations, you can get the results from the tidy3d.web.BatchData object directly, using for example sim_data_1 = batch_results[β€œsim_1”]. Or iterating over it in a loop, as below:


sim_data = []
for task_name, sim_data in batch_results.items():
  sim_data.append(sim_data)

In this notebook you will find a detailed example of how to run parameter sweeps.v