tidy3d.plugins.design.DesignSpace#
- class DesignSpace[source]#
Bases:
Tidy3dBaseModelSpecification of a design problem / combination of several parameters + algorithm.
- Parameters:
parameters (Attribute:
parameters) βTypeTuple[Union[ParameterInt, ParameterFloat, ParameterAny], β¦]
Default= ()
DescriptionSet of parameters defining the dimensions and allowed values for the design space.
method (Attribute:
method) βTypeUnion[MethodMonteCarlo, MethodGrid, MethodRandom, MethodRandomCustom]
DefaultDescriptionSpecifications for the procedure used to explore the parameter space.
name (Attribute:
name) βTypeOptional[str]
Default= None
DescriptionOptional name for the design space.
Example
>>> import tidy3d.plugins.design as tdd >>> param = tdd.ParameterFloat(name="x", span=(0,1)) >>> method = tdd.MethodMonteCarlo(num_points=10) >>> design_space = tdd.DesignSpace(parameters=[param], method=method) >>> fn = lambda x: x**2 >>> result = design_space.run(fn) >>> df = result.to_dataframe() >>> im = df.plot()
Attributes
Mapping of design parameter name to design parameter.
dimensions defined by the design parameter names.
methodDefines the methods used for parameter sweep.
Methods
get_fn_source(function)Get the function source as a string, return
Noneif not available.run(function,Β **kwargs)Run the design problem on a user defined function of the design parameters.
run_batch(fn_pre,Β fn_post[,Β path_dir])Run a design problem where the function is split into pre and post processing steps.
- parameters#
- method#
- name#
- property dims#
dimensions defined by the design parameter names.
- property design_parameter_dict#
Mapping of design parameter name to design parameter.
- static get_fn_source(function)[source]#
Get the function source as a string, return
Noneif not available.
- run(function, **kwargs)[source]#
Run the design problem on a user defined function of the design parameters.
- Parameters:
function (Callable) β Function accepting arguments that correspond to the
.namefields of theDesignSpace.parameters.- Returns:
Object containing the results of the design space exploration. Can be converted to
pandas.DataFramewith.to_dataframe().- Return type:
Result
- run_batch(fn_pre, fn_post, path_dir=None, **batch_kwargs)[source]#
Run a design problem where the function is split into pre and post processing steps.
- Parameters:
fn_pre (Callable[Union[SimulationData, List[SimulationData], Dict[str, SimulationData]], Any]) β Function accepting arguments that correspond to the
.namefields of theDesignSpace.parameters. Returns either aSimulation, list ofSimulation`s or a `dictof :class:`.Simulation`s to be run in a batch.fn_pre β Function accepting the
SimulationDataobject(s) corresponding to thefn_preand returning the result of the parameter sweep function. Iffn_prereturns a single simulation, it will be passed as a single argument tofn_post. Iffn_prereturns a list of simulations, their data will be passed as*args. Iffn_prereturns a dict of simulations, their data will be passed as**kwargswith the keys corresponding to the argument names.path_dir (str = None) β Optional directory in which to store the batch results.
- Returns:
Object containing the results of the design space exploration. Can be converted to
pandas.DataFramewith.to_dataframe().- Return type:
Result
- __hash__()#
Hash method.