Exemple #1
0
class SimulationSpace(optplan.SimulationSpaceBase):
    """Defines a simulation space.

    A simulation space contains information regarding the permittivity
    distributions but not the fields, i.e. no information regarding sources
    and wavelengths.

    Attributes:
        name: Name to identify the simulation space. Must be unique.
        eps_fg: Foreground permittivity.
        eps_bg: Background permittivity.
        mesh: Meshing information. This describes how the simulation region
            should be meshed.
        sim_region: Rectangular prism simulation domain.
        selection_matrix_type: The type of selection matrix to form. This
            is subject to change.
    """
    type = schema_utils.polymorphic_model_type("simulation_space")
    eps_fg = types.PolyModelType(EpsilonSpec)
    eps_bg = types.PolyModelType(EpsilonSpec)
    mesh = types.PolyModelType(MESH_TYPES)
    sim_region = types.ModelType(optplan.Box3d)
    boundary_conditions = types.ListType(
        types.PolyModelType(BOUNDARY_CONDITION_TYPES), min_size=6, max_size=6)
    pml_thickness = types.ListType(types.IntType(), min_size=6, max_size=6)
    selection_matrix_type = types.StringType(
        default=SelectionMatrixType.DIRECT.value,
        choices=tuple(select_type.value
                      for select_type in SelectionMatrixType),
    )
Exemple #2
0
class WaveguideInitializer3(Initializer):
    """Initializes parametrization using with a rectangular epsilon shape.

    The two levels of the step function can optionally have uniformly random
    initialization.

    Attributes:
        lower_min: minimum value of the lower (background) permittivity
        lower_max: maximum value of the lower (background) permittivity
        upper_min: minimum value of the upper (waveguide) permittivity
        upper_max: maximum value of the upper (waveguide) permittivity
        extent_frac_x:
        extent_frac_y:
        center_frac_x:
        center_frac_y:
    """
    type = schema_utils.polymorphic_model_type("initializer.waveguide_3")
    lower_min = types.FloatType()
    lower_max = types.FloatType()
    upper_min = types.FloatType()
    upper_max = types.FloatType()
    extent_frac_x = types.FloatType()
    extent_frac_y = types.FloatType()
    center_frac_x = types.FloatType()
    center_frac_y = types.FloatType()
Exemple #3
0
class BlochBoundary(schema_utils.Model):
    """Represents a Bloch boundary condition.

    Attributes:
        bloch_vector: 3D Bloch optplan.vector.
    """
    type = schema_utils.polymorphic_model_type("bloch")
    bloch_vector = optplan.vec3d(default=[0, 0, 0])
Exemple #4
0
class UniformMesh(schema_utils.Model):
    """Defines a uniform mesh.

    Attributes:
        type: Must be "uniform".
        dx: Unit cell distance for EM grid (nm).
    """
    type = schema_utils.polymorphic_model_type("uniform")
    dx = types.FloatType()
Exemple #5
0
class Parameter(optplan.Function):
    """Defines a constant scalar.

    Attributes:
        type: Must be "function.parameter".
        initial value: Value of the parameters when it is initialized.
    """
    type = schema_utils.polymorphic_model_type("function.parameter")
    initial_value = types.FloatType()
Exemple #6
0
class IndicatorPlus(optplan.Function):
    """Defines a penalty function to check if a function is above some value

    penalty = (obj>alpha)*(obj - alpha)**power
    """
    type = schema_utils.polymorphic_model_type("function.indicator_plus")
    function = optplan.ReferenceType(optplan.Function)
    alpha = types.FloatType()
    power = types.IntType()
Exemple #7
0
class Abs(optplan.Function):
    """Defines absolute value of a function.

    Attributes:
        type: Must be "abs".
        function: The function to take absolute value of.
    """
    type = schema_utils.polymorphic_model_type("function.abs")
    function = optplan.ReferenceType(optplan.Function)
Exemple #8
0
class Log10(optplan.Function):
    """Defines Log base 10 value of a function.

    Attributes:
        type: Must be "log".
        function: The function to take absolute value of.
    """
    type = schema_utils.polymorphic_model_type("function.log10")
    function = optplan.ReferenceType(optplan.Function)
Exemple #9
0
class CompositeParametrization(optplan.Parametrization):
    """Defines a composite parametrization.

    Attributes:
        param_list: List of parametrizations in the composite. Note that the
            ordering of the parametrizations should be match the ordering
            of selection matrices in the simulation space.
    """
    type = schema_utils.polymorphic_model_type("parametrization.composite")
    param_list = types.ListType(optplan.ReferenceType(optplan.Parametrization))
Exemple #10
0
class Power(optplan.Function):
    """Defines the power of a function.

    Attributes:
        type: Must be "power".
        function: Function to take power of.
        exp: Power.
    """
    type = schema_utils.polymorphic_model_type("function.power")
    function = optplan.ReferenceType(optplan.Function)
    exp = types.FloatType()
Exemple #11
0
class Constant(optplan.Function):
    """Defines a constant scalar.

    Attributes:
        type: Must be "function.constant".
        value: The constant value.
    """

    type = schema_utils.polymorphic_model_type("function.constant")
    value = types.ModelType(optplan.ComplexNumber,
                            default=optplan.ComplexNumber())
Exemple #12
0
class ImportOverlap(optplan.EmOverlap):
    """Represents a imported overlap vector.

    Attributes:
        file_name: .mat file containing the overlap vector.
        center: the center coordinate of the overlap, allows for translation
            of the overlap to the specified center.
    """
    type = schema_utils.polymorphic_model_type("overlap.import_field_vector")
    file_name = types.StringType()
    center = optplan.vec3d()
Exemple #13
0
class SimpleMonitor(optplan.Monitor):
    """Defines a monitor.

    A monitor takes the output of a scalar function.

    Attributes:
        type: Must be "monitor.scalar".
        function: Name of function to monitor.
    """
    type = schema_utils.polymorphic_model_type("monitor.simple")
    function = optplan.ReferenceType(optplan.Function)
Exemple #14
0
class GratingParametrization(optplan.Parametrization):
    """Defines a `GratingParam`.

    The grating is by default initialized to have no structure.

    Attributes:
        type: Must be "parametrization.grating_edge".
        simulation_space: Simulation space to use parametrization in.
    """
    type = schema_utils.polymorphic_model_type("parametrization.grating")
    simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase)
Exemple #15
0
class Overlap(optplan.Function):
    """Defines an overlap integral.

    Attributes:
        type: Must be "function.overlap".
        simulation: Simulation from which electric fields are obtained.
        overlap: Overlap type to use.
    """
    type = schema_utils.polymorphic_model_type("function.overlap")
    simulation = optplan.ReferenceType(optplan.Function)
    overlap = optplan.ReferenceType(optplan.EmOverlap)
Exemple #16
0
class PixelParametrization(optplan.Parametrization):
    """Defines a `DirectParam`.

    Attributes:
        type: Must be "parametrization.pixel".
        init_method: Initialization condition.
        simulation_space: Simulation space to use parametrization in.
    """
    type = schema_utils.polymorphic_model_type("parametrization.direct")
    simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase)
    init_method = optplan.ReferenceType(Initializer)
Exemple #17
0
class PhaseAbsolute(optplan.Function):
    """Defines a function that returns the absolute phase of the field.

    Attributes:
        type: Must be "function.phase_absolute".
        simulation: Simulation from which electric fields are obtained.
    """
    type = schema_utils.polymorphic_model_type("function.phase_absolute")
    simulation = optplan.ReferenceType(optplan.Function)
    region = optplan.ReferenceType(optplan.EmRegion)
    path = optplan.ReferenceType(optplan.EmRegion)
Exemple #18
0
class UniformInitializer(Initializer):
    """Initializes parametrization uniformly at random.

    The parametrization values are initialized element-wise.

    Attributes:
        min_val: Minimum value of distribution.
        max_val: Maximum value of distribution.
    """
    type = schema_utils.polymorphic_model_type("initializer.uniform_random")
    min_val = types.FloatType()
    max_val = types.FloatType()
Exemple #19
0
class GratingFeatureConstraint(optplan.Function):
    """Defines a feature constraint on `GratingParametrization`.

    Args:
        simulation_space: Used to extract the number of pixels in the design
            region.
        min_feature_size: Minimum feature size in nm.
    """
    type = schema_utils.polymorphic_model_type(
        "function.grating_feature_constraint")
    simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase)
    min_feature_size = types.FloatType()
Exemple #20
0
class NormalInitializer(Initializer):
    """Initializes parametrization using normal distribution.

    The parametrization values are initialized element-wise by a normal
    distribution.

    Attributes:
        mean: Mean value of the normal distribution.
        std: Standard deviation value of the normal distribution.
    """
    type = schema_utils.polymorphic_model_type("initializer.normal")
    mean = types.FloatType()
    std = types.FloatType()
Exemple #21
0
class DiffEpsilon(optplan.Function):
    """Defines a function that finds the L1 norm between two permittivities.

    Specifially, the function is defined as `sum(|epsilon - epsilon_ref|)`.

    Attributes:
        type: Must be "function.diff_epsilon".
        epsilon: Permittivity.
        epsilon_ref: Base permittivity to compare to.
    """
    type = schema_utils.polymorphic_model_type("function.diff_epsilon")
    epsilon = optplan.ReferenceType(optplan.Function)
    epsilon_ref = types.PolyModelType(EpsilonSpec)
Exemple #22
0
class Epsilon(optplan.Function):
    """Defines a Epsilon Grid.

    Attributes:
        type: Must be "function.epsilon".
        name: Name of epsilon.
        simulation_space: Simulation space name.
        wavelength: Wavelength at which to calculate epsilon.
    """
    type = schema_utils.polymorphic_model_type("function.epsilon")
    simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase)
    wavelength = types.FloatType()
    structure = optplan.ReferenceType(optplan.Parametrization)
Exemple #23
0
class ParamEps(EpsilonSpec):
    """Defines a permittivity distribution based on a parametriation.

    Attributes:
        type: Must be "parametrization".
        parametrization: Name of the parametrization.
        simulation_space: Name of the simulation space.
        wavelength: Wavelength.
    """
    type = schema_utils.polymorphic_model_type("parametrization")
    parametrization = optplan.ReferenceType(optplan.Parametrization)
    simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase)
    wavelength = types.FloatType()
Exemple #24
0
class PowerComp(optplan.Function):
    """Defines a penalty function to check if a function is in a certain range.

    penalty = R(f-(value-range/2))**exp+R((value-range/2)-f),
    where R is a ramp function.

    Attributes:
        type: Must be "function.power_comp".
    """
    type = schema_utils.polymorphic_model_type("function.power_comp")
    function = optplan.ReferenceType(optplan.Function)
    value = types.FloatType()
    range = types.FloatType()
    exp = types.FloatType()
Exemple #25
0
class CubicParamSigmoidStrength(optplan.TransformationBase):
    """Changes the strength of the sigmoid function in `CubicParametrization`.

    `CubicParametrization` applies a sigmoid function after cubic interpolation
    to make the structure more discrete. This transformation changes the
    parameter in the sigmoid function, effectively changing how discrete the
    structure becomes. In the limit as the value tends to infinity, the sigmoid
    function becomes a step function (i.e. perfectly discrete structure).

    Attributes:
        value: Value for sigmoid function.
    """
    type = schema_utils.polymorphic_model_type("cubic_param.sigmoid_strength")
    value = types.FloatType(default=4)
Exemple #26
0
class GratingFeatureConstraint(optplan.Function):
    """Defines a feature constraint on `GratingParametrization`.

    Args:
        simulation_space: Used to extract the number of pixels in the design
            region.
        min_feature_size: Minimum feature size in nm.
        boundary_constraint_scale: See `spins.invdes.problem.GratingConstraint`
            for details.
    """
    type = schema_utils.polymorphic_model_type(
        "function.grating_feature_constraint")
    simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase)
    min_feature_size = types.FloatType()
    boundary_constraint_scale = types.FloatType(default=2.0)
Exemple #27
0
class GratingParametrization(optplan.Parametrization):
    """Defines a `GratingParam`.

    The grating is by default initialized to have no structure.

    Attributes:
        type: Must be "parametrization.grating_edge".
        simulation_space: Simulation space to use parametrization in.
        inverted: If `True`, defines a grating where each pair of edges
            correspond to a "hole". See
            `spins.invdes.parametrization.GratingParam` for details.
    """
    type = schema_utils.polymorphic_model_type("parametrization.grating")
    simulation_space = optplan.ReferenceType(optplan.SimulationSpaceBase)
    inverted = types.BooleanType(default=False)
Exemple #28
0
class ContToDiscThresholding(optplan.TransformationBase):
    """Defines a transformation that takes a continuous parametrization and
    thresholds it at a value.

    Attributes:
        type: Must be "cont_to_disc_thresholding".
        value: Threshold value.

    Note that this requests requires the parametrization to have the same
    parametrization  vector size, e.g. cubic to bicubic or hermiteparam
    to hermitelevelset.
    """
    type = schema_utils.polymorphic_model_type("cont_to_disc_thresholding")
    continuous_parametrization = optplan.ReferenceType(optplan.Parametrization)
    threshold = types.FloatType()
Exemple #29
0
class GratingEdgeFitTransformation(optplan.TransformationBase):
    """Defines the discretization procedure for gratings.

    Specifically, this will convert any epsilon description into a
    `GratingEdgeParametrization`.

    Attributes:
        parametrization: Parametrization to match structure to.
        min_feature: Minimum feature size in terms of number of pixels. Can be
            fractional.
    """
    type = schema_utils.polymorphic_model_type(
        "grating_edge_fit_transformation")
    parametrization = optplan.ReferenceType(optplan.Parametrization)
    min_feature = types.FloatType()
Exemple #30
0
class SlabMesh(Mesh):
    """Defines a slab.

    A slab is a rectangular prism that has a finite extent along the extrusion
    axis and infinite extent in the other two directions. Slabs are commonly
    used to draw a background permittivity distribution before drawing
    other meshes.

    Attributes:
        material: Material to use for slab.
        extents: Start and end location of slab in the extrusion direction.
    """
    type = schema_utils.polymorphic_model_type("mesh.slab")
    material = types.ModelType(Material)
    extents = optplan.vec2d()