emopt.fomutils¶
Common functions useful for calculating figures of merit and their derivatives.
-
class
emopt.fomutils.ModeMatch(normal, ds1, ds2=1.0, Exm=None, Eym=None, Ezm=None, Hxm=None, Hym=None, Hzm=None)¶ Bases:
future.types.newobject.newobjectCompute the mode match between two sets of electromagnetic fields.
The mode match is essentially a projection of one set of fields onto a second set of fields. It defines the fraction of power in field 1 which propagates in field 2.
When normalized with respect to the total source power injected into a system, this function can be used to compute coupling efficiencies.
See [1] for a detailed derivation of the mode match equation.
References
[1] A. Michaels, E. Yablonovitch, “Gradient-Based Inverse Electromagnetic Design Using Continuously-Smoothed Boundaries,” Arxiv, 2017
Parameters: - normal (list or tuple) – The normal direction of the plane in which the mode match is computed in the form (x,y,z).
- ds1 (float) – The grid spacing along the first dimension of the supplied fields
- ds2 (float (optional)) – The grid spacing along the second dimension of the supplied fields. For 1D mode matches, leave this untouched. (default = 1.0)
- Exm (numpy.ndarray (optional)) – The x component of the reference electric field
- Eym (numpy.ndarray (optional)) – The y component of the reference electric field
- Ezm (numpy.ndarray (optional)) – The z component of the reference electric field
- Hxm (numpy.ndarray (optional)) – The x component of the reference magnetic field
- Hym (numpy.ndarray (optional)) – The y component of the reference magnetic field
- Hzm (numpy.ndarray (optional)) – The z component of the reference magnetic field
-
compute(Ex=None, Ey=None, Ez=None, Hx=None, Hy=None, Hz=None)¶ Compute the mode match and other underlying quantities.
-
get_mode_match_forward(P_in)¶ Get the mode match in the forward direction normalized with respect to a desired power.
-
get_mode_match_back(P_in)¶ Get the mode match in the backwards direction normalized with respect to a desired power.
-
get_dFdEx()¶ Get the derivative of unnormalized mode match with respect to Ex
-
get_dFdEy()¶ Get the derivative of unnormalized mode match with respect to Ey
-
get_dFdEz()¶ Get the derivative of unnormalized mode match with respect to Ez
-
get_dFdHx()¶ Get the derivative of unnormalized mode match with respect to Hx
-
get_dFdHy()¶ Get the derivative of unnormalized mode match with respect to Hy
-
get_dFdHz()¶ Get the derivative of unnormalized mode match with respect to Hz
-
compute(Ex=None, Ey=None, Ez=None, Hx=None, Hy=None, Hz=None) Compute the mode match and other underlying quantities.
Notes
This function must be called befor getting the mode match efficiency.
If a NULL field is passed, it is assumed to be zero and have the correct dimensions.
Parameters: - Ex (numpy.ndarray (optional)) – The x component of the electric field. (default = None)
- Ey (numpy.ndarray (optional)) – The y component of the electric field. (default = None)
- Ez (numpy.ndarray (optional)) – The z component of the electric field. (default = None)
- Hx (numpy.ndarray (optional)) – The x component of the magnetic field. (default = None)
- Hy (numpy.ndarray (optional)) – The y component of the magnetic field. (default = None)
- Hz (numpy.ndarray (optional)) – The z component of the magnetic field. (default = None)
-
get_dFdEx() Get the derivative of unnormalized mode match with respect to Ex.
Returns: The derivative of the unnormalized mode match with respect to the x component of the electric field. Return type: numpy.ndarray
-
get_dFdEy() Get the derivative of unnormalized mode match with respect to Ey.
Returns: The derivative of the unnormalized mode match with respect to the y component of the electric field. Return type: numpy.ndarray
-
get_dFdEz() Get the derivative of unnormalized mode match with respect to Ez.
Returns: The derivative of the unnormalized mode match with respect to the z component of the electric field. Return type: numpy.ndarray
-
get_dFdHx() Get the derivative of unnormalized mode match with respect to Hx.
Returns: The derivative of the unnormalized mode match with respect to the x component of the magnetic field. Return type: numpy.ndarray
-
get_dFdHy() Get the derivative of unnormalized mode match with respect to Hy.
Returns: The derivative of the unnormalized mode match with respect to the y component of the magnetic field. Return type: numpy.ndarray
-
get_dFdHz() Get the derivative of unnormalized mode match with respect to Hz.
Returns: The derivative of the unnormalized mode match with respect to the z component of the magnetic field. Return type: numpy.ndarray
-
emopt.fomutils.d_ndisty_dx1(x1, x2, x3, y1, y2, y3, y0)¶ Calculate the derivative of ndisty with respect the the x coordinate of the ‘previous’ point.
Parameters: - x1 (float or list or np.array) – X coordinate(s) of “previous” point
- x2 (float or list or np.array) – X coordinate(s) of “current” point
- x3 (float or list or np.array) – X coordinate(s) of “next” point
- y1 (float or list or np.array) – Y coordinate(s) of “previous” point
- y2 (float or list or np.array) – Y coordinate(s) of “current” point
- y3 (float or list or np.array) – Y coordinate(s) of “next” point
- y0 (float) – The y position to which the distance is calculated.
Returns: List of derivatives with length N-2 where N=len(x)
Return type: np.array
-
emopt.fomutils.d_ndisty_dx2(x1, x2, x3, y1, y2, y3, y0)¶ Calculate the derivative of ndisty with respect the the x coordinate of the ‘current’ point.
Parameters: - x1 (float or list or np.array) – X coordinate(s) of “previous” point
- x2 (float or list or np.array) – X coordinate(s) of “current” point
- x3 (float or list or np.array) – X coordinate(s) of “next” point
- y1 (float or list or np.array) – Y coordinate(s) of “previous” point
- y2 (float or list or np.array) – Y coordinate(s) of “current” point
- y3 (float or list or np.array) – Y coordinate(s) of “next” point
- y0 (float) – The y position to which the distance is calculated.
Returns: List of derivatives with length N-2 where N=len(x)
Return type: np.array
-
emopt.fomutils.d_ndisty_dx3(x1, x2, x3, y1, y2, y3, y0)¶ Calculate the derivative of ndisty with respect the the x coordinate of the ‘next’ point.
Parameters: - x1 (float or list or np.array) – X coordinate(s) of “previous” point
- x2 (float or list or np.array) – X coordinate(s) of “current” point
- x3 (float or list or np.array) – X coordinate(s) of “next” point
- y1 (float or list or np.array) – Y coordinate(s) of “previous” point
- y2 (float or list or np.array) – Y coordinate(s) of “current” point
- y3 (float or list or np.array) – Y coordinate(s) of “next” point
- y0 (float) – The y position to which the distance is calculated.
Returns: List of derivatives with length N-2 where N=len(x)
Return type: np.array
-
emopt.fomutils.d_ndisty_dy1(x1, x2, x3, y1, y2, y3, y0)¶ Calculate the derivative of ndisty with respect the the y coordinate of the ‘previous’ point.
Parameters: - x1 (float or list or np.array) – X coordinate(s) of “previous” point
- x2 (float or list or np.array) – X coordinate(s) of “current” point
- x3 (float or list or np.array) – X coordinate(s) of “next” point
- y1 (float or list or np.array) – Y coordinate(s) of “previous” point
- y2 (float or list or np.array) – Y coordinate(s) of “current” point
- y3 (float or list or np.array) – Y coordinate(s) of “next” point
- y0 (float) – The y position to which the distance is calculated.
Returns: List of derivatives with length N-2 where N=len(x)
Return type: np.array
-
emopt.fomutils.d_ndisty_dy2(x1, x2, x3, y1, y2, y3, y0)¶ Calculate the derivative of ndisty with respect the the y coordinate of the ‘current’ point.
Parameters: - x1 (float or list or np.array) – X coordinate(s) of “previous” point
- x2 (float or list or np.array) – X coordinate(s) of “current” point
- x3 (float or list or np.array) – X coordinate(s) of “next” point
- y1 (float or list or np.array) – Y coordinate(s) of “previous” point
- y2 (float or list or np.array) – Y coordinate(s) of “current” point
- y3 (float or list or np.array) – Y coordinate(s) of “next” point
- y0 (float) – The y position to which the distance is calculated.
Returns: List of derivatives with length N-2 where N=len(x)
Return type: np.array
-
emopt.fomutils.d_ndisty_dy3(x1, x2, x3, y1, y2, y3, y0)¶ Calculate the derivative of ndisty with respect the the y coordinate of the ‘next’ point.
Parameters: - x1 (float or list or np.array) – X coordinate(s) of “previous” point
- x2 (float or list or np.array) – X coordinate(s) of “current” point
- x3 (float or list or np.array) – X coordinate(s) of “next” point
- y1 (float or list or np.array) – Y coordinate(s) of “previous” point
- y2 (float or list or np.array) – Y coordinate(s) of “current” point
- y3 (float or list or np.array) – Y coordinate(s) of “next” point
- y0 (float) – The y position to which the distance is calculated.
Returns: List of derivatives with length N-2 where N=len(x)
Return type: np.array
-
emopt.fomutils.d_roc_dx1(x1, x2, x3, y1, y2, y3)¶ Calculate the derivative of the radius of curvature with respect to the changes in the x coordinate of the point.
This function calculates the derivative of the approximate radius of curvature at a point (x2, y2) with respect to x1.
Notes
Currently this is computed using a finite difference which will introduce a small amount of error and be slightly less performant than an analytic implementation. An analytic implementation will be implemented soon!
Parameters: Returns: The derivative of the approximate radius of curvature at point (x2, y2) with respect to x1.
Return type:
-
emopt.fomutils.d_roc_dx2(x1, x2, x3, y1, y2, y3)¶ Calculate the derivative of the radius of curvature with respect to the changes in the x coordinate of the point.
This function calculates the derivative of the approximate radius of curvature at a point (x2, y2) with respect to x2.
Notes
Currently this is computed using a finite difference which will introduce a small amount of error and be slightly less performant than an analytic implementation. An analytic implementation will be implemented soon!
Parameters: Returns: The derivative of the approximate radius of curvature at point (x2, y2) with respect to x2.
Return type:
-
emopt.fomutils.d_roc_dx3(x1, x2, x3, y1, y2, y3)¶ Calculate the derivative of the radius of curvature with respect to the changes in the x coordinate of the point.
This function calculates the derivative of the approximate radius of curvature at a point (x2, y2) with respect to x3.
Notes
Currently this is computed using a finite difference which will introduce a small amount of error and be slightly less performant than an analytic implementation. An analytic implementation will be implemented soon!
Parameters: Returns: The derivative of the approximate radius of curvature at point (x2, y2) with respect to x3.
Return type:
-
emopt.fomutils.d_roc_dy1(x1, x2, x3, y1, y2, y3)¶ Calculate the derivative of the radius of curvature with respect to the changes in the y coordinate of the point.
This function calculates the derivative of the approximate radius of curvature at a point (x2, y2) with respect to y1.
Notes
Currently this is computed using a finite difference which will introduce a small amount of error and be slightly less performant than an analytic implementation. An analytic implementation will be implemented soon!
Parameters: Returns: The derivative of the approximate radius of curvature at point (x2, y2) with respect to y1.
Return type:
-
emopt.fomutils.d_roc_dy2(x1, x2, x3, y1, y2, y3)¶ Calculate the derivative of the radius of curvature with respect to the changes in the y coordinate of the point.
This function calculates the derivative of the approximate radius of curvature at a point (x2, y2) with respect to y2.
Notes
Currently this is computed using a finite difference which will introduce a small amount of error and be slightly less performant than an analytic implementation. An analytic implementation will be implemented soon!
Parameters: Returns: The derivative of the approximate radius of curvature at point (x2, y2) with respect to y2.
Return type:
-
emopt.fomutils.d_roc_dy3(x1, x2, x3, y1, y2, y3)¶ Calculate the derivative of the radius of curvature with respect to the changes in the y coordinate of the point.
This function calculates the derivative of the approximate radius of curvature at a point (x2, y2) with respect to y3.
Notes
Currently this is computed using a finite difference which will introduce a small amount of error and be slightly less performant than an analytic implementation. An analytic implementation will be implemented soon!
Parameters: Returns: The derivative of the approximate radius of curvature at point (x2, y2) with respect to y3.
Return type:
-
emopt.fomutils.dist_to_edges(x1, x2, x3, y1, y2, y3, xe, ye)¶ Calculate the signed distance to a set of edges.
Given a set of three points (x1, y1), (x2, y2), and (x3, y3) calculate the distance from (x2, y2) to the edges defined by lists of coordinates xe and ye. These distances typically correspond to gaps and bridges in a polygon.
Parameters: - x1 (float) – The x coordinate of the “previous” point
- y1 (float) – The y coordinate of the “previous” point
- x2 (float) – The x coordinate of the “current” point
- y2 (float) – The y coordinate of the “current” point
- x3 (float) – The x coordinate of the “next” point
- y3 (float) – The y coordinate of the “next” point
- xe (float) – The list of x coordinates which define a polygon
- ye (float) – The list of y coordinates which define a polygon
Returns: - np.array – The list of signed distances from point (x2, y2) to the edges defined by xe and ye. The number of distances will be equal to the number of edges in the polygon.
- np.array – Parameters used to define edge lines. An intersection with an edge occurs when these parameters are between 0 and 1
-
emopt.fomutils.interpolated_dFdx_2D(sim, dFdEzi, dFdHxi, dFdHyi)¶ Account for interpolated fields in a ‘naive’ derivative of a figure of merit.
In order to calculate any sort of quantity that involves power flow, we must interpolate the fields such that they are all known at the same point in space. This process of interpolation must be handled very carefully in the contex of calculating gradients of a figure of merit. In order to simplify this process and minimize the number of errors made, you can naively calculate the derivatives with respect to the interpolated fields and then compensate in order to ensure that the derivatives are correct with respect to the ‘True’ undelying shifted fields.
Notes
- This function modifies the input arrays.
- dFdEz is not modified in the TE case
Parameters: - dFdEz (numpy.array) – 2D numpy array containing derivative of FOM with respect to INTERPOLATED Ez
- dFdHx (numpy.array) – 2D numpy array containing derivative of FOM with respect to INTERPOLATED Hx
- dFdHy (numpy.array) – 2D numpy array containing derivative of FOM with respect to INTERPOLATED Hy
Returns: The modified derivatives which account for interpolation
Return type: numpy.array, numpy.array, numpy.array
-
emopt.fomutils.interpolated_dFdx_3D(sim, domain, dFdExi, dFdEyi, dFdEzi, dFdHxi, dFdHyi, dFdHzi)¶ Account for interpolated fields in a ‘naive’ derivative of a figure of merit.
In order to calculate any sort of quantity that involves power flow, we must interpolate the fields such that they are all known at the same point in space. This process of interpolation must be handled very carefully in the contex of calculating gradients of a figure of merit. In order to simplify this process and minimize the number of errors made, you can naively calculate the derivatives with respect to the interpolated fields and then compensate in order to ensure that the derivatives are correct with respect to the ‘True’ undelying shifted fields.
Notes
Not all of the symmetry options have been tested. If you encounter issues with gradient accuracy, please post an issue on github!
Parameters: - sim (fdfd.FDFD_3D) – The simulation object–needed for boundary condition information
- domain (misc.DomainCoordinates) – The domain in which the derivative of the FOM has been computed
- dFdEx (numpy.array) – 3D numpy array containing derivative of FOM with respect to INTERPOLATED Ex
- dFdEy (numpy.array) – 3D numpy array containing derivative of FOM with respect to INTERPOLATED Ey
- dFdEz (numpy.array) – 3D numpy array containing derivative of FOM with respect to INTERPOLATED Ez
- dFdHx (numpy.array) – 2D numpy array containing derivative of FOM with respect to INTERPOLATED Hx
- dFdHy (numpy.array) – 2D numpy array containing derivative of FOM with respect to INTERPOLATED Hy
- dFdHz (numpy.array) – 2D numpy array containing derivative of FOM with respect to INTERPOLATED Hz
Returns: - misc.DomainCoordinates, numpy.ndarray, numpy.ndarray, numpy.ndarray,
- numpy.ndarray, numpy.ndarray, numpy.ndarray – The modified derivatives which account for interpolation and the modified DomainCoordinates
-
emopt.fomutils.ndisty(x, y, y0)¶ Calculate the approximate distance from each point in a polygon to a y position along the polygon normal direction.
Given a polygon defined by a set of x and y coordinates, find the distance from each point in that polygon to a desired y position. The normal direction is approximated based on the surrounding points.s
Parameters: Returns: List of distances with length N-2 where N=len(x)
Return type: np.array
-
emopt.fomutils.ndisty_penalty(x, y, y0, dmin, delta_d, inds=None)¶ Calculate a penalty function based on the minimum distance from each point to a y coordinate.
This distance is calculated along the approximate normal direction of the polygon at each point. A thresholding function is applied to the distance in order to compare it to a minimum distance and hence determine a penalty value.
This is useful as a simple approximate gap size constraint. For example, if a device is symmetric about y=0, you can call this function with y0=0 to penalize points which get too close to the y axis.
Notes
The inds parameter may not contain 0 or N-1 where N is the length of x and y.
Parameters: - x (list or np.array) – X coordinates of polygon
- y (list or np.array) – Y coordinates of polygon
- y0 (float) – The y position to which the distance is calculated.
- dmin (float) – The minimum distance.
- delta_d (float) – The steepness of the threshold function.
- inds (numpy.array (optional)) – The set of indices of x,y for which the penalty is calculated. If None, then the penalty will be calculated at all but the end points (default = None)
Returns: The value of the penalty.
Return type:
-
emopt.fomutils.ndisty_penalty_derivative(x, y, y0, dmin, delta_d, inds=None)¶ Calculate the derivative of ndisty_penalty with respect to the x and y coordinates.
Notes
The inds parameter may not contain 0 or N-1 where N is the length of x and y.
Parameters: - x (list or np.array) – X coordinates of polygon
- y (list or np.array) – Y coordinates of polygon
- y0 (float) – The y position to which the distance is calculated.
- dmin (float) – The minimum distance.
- delta_d (float) – The steepness of the threshold function.
- inds (numpy.array (optional)) – The set of indices of x,y for which the penalty is calculated. If None, then the penalty will be calculated at all but the end points (default = None)
Returns: The derivatives with respect to the x and y coordinates, respectively.
Return type: numpy.ndarray, numpy.ndarray
-
emopt.fomutils.power_norm_dFdx(sim, f, dfdA1, dfdA2, dfdA3)¶
-
emopt.fomutils.power_norm_dFdx_3D(sim, f, domain, dfdEx, dfdEy, dfdEz, dfdHx, dfdHy, dfdHz)¶ Compute the derivative of a figure of merit which has power normalization.
The behavior of this function is very similar to its 2D counterparts.
Notes
Currently, this function does NOT account for the fact that the fields are interpolated. This will lead to some finite amount of error in the gradient calculations. In most cases, this increased error should not cause any issues.
Parameters: - sim (emopt.fdfd.FDFD_3D) – simulation object which is needed in order to access field components as well as grid parameters
- f (float) – current value of merit function
- dfdEx (numpy.ndarray) – derivative w.r.t. Ex of non-normalized figure of merit
- dfdEy (numpy.ndarray) – derivative w.r.t. Ey of non-normalized figure of merit
- dfdEz (numpy.ndarray) – derivative w.r.t. Ez of non-normalized figure of merit
- dfdHx (numpy.ndarray) – derivative w.r.t. Hx of non-normalized figure of merit
- dfdHy (numpy.ndarray) – derivative w.r.t. Hy of non-normalized figure of merit
- dfdHz (numpy.ndarray) – derivative w.r.t. Hy of non-normalized figure of merit
Returns: List of source arrays and domains in the format needed by emotp.fdfd.FDFD_3D.set_adjoint_source(src)
Return type:
-
emopt.fomutils.power_norm_dFdx_TE(sim, f, dfdEz, dfdHx, dfdHy)¶ Compute the derivative of a figure of merit which has power normalization.
In many if not most cases of electromagnetic optimization, we will consider optimization problems in which we want to maximize some quantity which is normalized with respect to the total source power leaving a source, i.e.
F(E,H) = f(E,H)/PsrcIn some cases (e.g. a dipole emitting into a dielectric structure), the source power will depend on the shape of the structure itself. As a result, we need to account for this in our gradient calculations.
Fortunately, we can easily account for this by writing our merit function as
F(E,H) = f(E,H)/Psrc(E,H)and taking the necessary derivatives of Psrc. This process requires no deep knowledge about f. It only needs f and its (numerical) derivative.
Notes
1. This function assumes f(E,H) is a function of the INTERPOLATED fields. All interpolation compensation is taken care of here (so don’t call interp_dFdx on the dfdx’s!!)
Parameters: - sim (emopt.fdfd.FDFD_TE) – simulation object which is needed in order to access field components as well as grid parameters
- f (float) – current value of merit function
- dfdEz (numpy.ndarray) – derivative w.r.t. Ez of non-normalized figure of merit
- dfdHx (numpy.ndarray) – derivative w.r.t. Hx of non-normalized figure of merit
- dfdHy (numpy.ndarray) – derivative w.r.t. Hy of non-normalized figure of merit
Returns: The derivative of the full power-normalized figure of merit with interpolation accounted for.
Return type: numpy.ndarray, numpy.ndarray, numpy.ndarray
-
emopt.fomutils.power_norm_dFdx_TM(sim, f, dfdHz, dfdEx, dfdEy)¶ Compute the derivative of a figure of merit which has power normalization.
In many if not most cases of electromagnetic optimization, we will consider optimization problems in which we want to maximize some quantity which is normalized with respect to the total source power leaving a source, i.e.
F(E,H) = f(E,H)/PsrcIn some cases (e.g. a dipole emitting into a dielectric structure), the source power will depend on the shape of the structure itself. As a result, we need to account for this in our gradient calculations.
Fortunately, we can easily account for this by writing our merit function as
F(E,H) = f(E,H)/Psrc(E,H)and taking the necessary derivatives of Psrc. This process requires no deep knowledge about f. It only needs f and its (numerical) derivative.
Notes
1. This function assumes f(E,H) is a function of the INTERPOLATED fields. All interpolation compensation is taken care of here (so don’t call interp_dFdx on the dfdx’s!!)
Parameters: - sim (emopt.fdfd.FDFD_TM) – simulation object which is needed in order to access field components as well as grid parameters
- f (float) – current value of merit function
- dfdEz (numpy.ndarray) – derivative w.r.t. Ez of non-normalized figure of merit
- dfdHx (numpy.ndarray) – derivative w.r.t. Hx of non-normalized figure of merit
- dfdHy (numpy.ndarray) – derivative w.r.t. Hy of non-normalized figure of merit
Returns: The derivative of the full power-normalized figure of merit with interpolation accounted for.
Return type: numpy.ndarray, numpy.ndarray, numpy.ndarray
-
emopt.fomutils.radius_of_curvature(x1, x2, x3, y1, y2, y3)¶ Compute the approximate radius of curvature of three points.
This is achieved by first fitting a parabola to the three points and then finding the radius of cruvature of that parabola.
Notes
The radius of curvature is signed.
Parameters: Returns: The approximate radius of curvature of the set of points
Return type:
-
emopt.fomutils.rect(x, w1p, ws)¶ Apply a smooth rect function.
This function is centered at zero.
Parameters: Returns: The value of rect(x).
Return type: float or numpy.ndarray
-
emopt.fomutils.rect_derivative(x, w1p, ws)¶ Calculate the derivative of the smoothed rect function.
Parameters: Returns: The value of \(d \mathrm{rect} / dt |_x\).
Return type: float or numpy.ndarray
-
emopt.fomutils.rocp(x, y, indices, Rmin, dR)¶ Calculate a penalty which acts as a minimum radius of curvature constraint.
A radius of curvature constraint can be imposed by first calculating the approximate radius of curvature at every point and then penalizing a figure of merit when radii of curvature fall below a minimum value. Penalization is achieved by applying a (smooth) rect function to the radii of curvature; when a radius is below a specified minimum, the resulting output of the function drops below zero, reducing the figure of merit.
Parameters: - x (numpy.ndarray) – The x coordinates of a polygon or connected set of points
- y (numpy.ndarray) – The y coordinates of a polygon or connected set of points
- indices (list or numpy.ndarray) – The list of array indices for which the radius of curvature is calculated
- Rmin (float) – The minimum radius of curvature
- dR (float) – The steepness of the step function used to determine violation of Rmin
Returns: The values of the radius of curvature penalty function.
Return type:
-
emopt.fomutils.rocp_derivative(x, y, indices, Rmin, dR)¶ Calculate the derivative of the radius of curvature penalty with respect to the set of (x,y) coordinates.
Notes
This function assumes that the indices are ‘sorted’, i.e., the indices correspond to moving clockwise or counter-clockwise around the line string/polygon. The function will not work if the points are out of order.
Parameters: - x (numpy.ndarray) – The x coordinates of a polygon or connected set of points
- y (numpy.ndarray) – The y coordinates of a polygon or connected set of points
- indices (list or numpy.ndarray) – The list of array indices for which the radius of curvature is calculated
- Rmin (float) – The minimum radius of curvature
- dR (float) – The steepness of the step function used to determine violation of Rmin
Returns: Two lists containing d/dx(rocp) and d/dy(rocp)
Return type: np.array, np.array
-
emopt.fomutils.step(x, k, y0=0, A=1.0)¶ Compute the value of a smooth and analytic step function.
The step function is approximated using a logistic function which can be scaled and shifted:
\[\Pi(x) = \frac{A}{1 + e^{-k x}} + y_0\]This function has the property that \(\Pi \rightarrow y_0\) as \(x \rightarrow -\infty\) and \(\Pi \rightarrow y_0 + A\) as \(x \rightarrow \infty\).
Parameters: Returns: The step function applied to x.
Return type: float or numpy.ndarray