simpson_integration.py¶
-
openconcept.utilities.math.simpson_integration.simpson_integral(dts, q, n_segments=1, n_simpson_intervals_per_segment=2)[source]¶ This method integrates a rate over time using Simpson’s rule
A “segment” is defined as a portion of the quantity vector q with a constant delta t (or delta x, etc) dts = list of doubles representing the time steps for each segment. This is the data timestep - the interval timestep is 2x this q = the data to be integrated n_segments = how many segments n_simpson_intervals_per_segment = how many simpson intervals to use per segment. Each one requires 2*N+1 data points
Returns: - delta_q (float) – Amount of q accumulated during each interval (vector)
- int_q (float) – Total amount of q accumulated during all phases (scalar)
-
openconcept.utilities.math.simpson_integration.simpson_partials(dts, q, n_segments=1, n_simpson_intervals_per_segment=2)[source]¶ This method integrates a rate over time using Simpson’s rule
A “segment” is defined as a portion of the quantity vector q with a constant delta t (or delta x, etc) dts = list of doubles representing the time steps for each segment. This is the data timestep - the interval timestep is 2x this q = the data to be integrated n_segments = how many segments n_simpson_intervals_per_segment = how many simpson intervals to use per segment. Each one requires 2*N+1 data points
Returns: - delta_q (float) – Amount of q accumulated during each interval (vector)
- int_q (float) – Total amount of q accumulated during all phases (scalar)
-
openconcept.utilities.math.simpson_integration.simpson_integral_every_node(dts, q, n_segments=1, n_simpson_intervals_per_segment=2)[source]¶ This method integrates a rate over time using Simpson’s rule and assumes that q linearly changes within the Simpson subintervals. Unlike the intervals above, this method returns a vector of length nn-1 instead of nn-1/2 A “segment” is defined as a portion of the quantity vector q with a constant delta t (or delta x, etc) dts = list of doubles representing the time steps for each segment. This is the data timestep - the interval timestep is 2x this q = the data to be integrated n_segments = how many segments n_simpson_intervals_per_segment = how many simpson intervals to use per segment. Each one requires 2*N+1 data points
returns: delta_q = amount of q accumulated during each interval (corresponds to the intervals between q, 2x as often as the simpson subintervals) int_q = total amount of q accumulated during all phases
-
class
openconcept.utilities.math.simpson_integration.IntegrateQuantity(**kwargs)[source]¶ Bases:
openmdao.core.explicitcomponent.ExplicitComponentThis component integrates a first-order rate quantity vector over a differential with CONSTANT spacing using Simpson’s 3rd order method. Inputs: rate (vector) - rate of change of a quantity q with respect to the differential. E.g. if your differential is time, the rate should be dq/dt. Length must be 2*N+1 lower_limit (scalar) - the lower limit of the integral. e.g. if your differential var is time, lower_limit is t0 upper_limit (scalar) - the upper limit of the integral. e.g. if your differential var is time, upper limit is tf Outputs: delta_quantity: the total change in the quantity over the integral period. E.g. if integrating rate dq/dt wrt t, output is total change in q Options: num_intervals: Number of Simpson integration intevals to use. Length of the rate input vector will be 2*N+1 quantity_units: Units of quantity (not including the rate) e.g. kg NOT kg/s diff_units: Units of the differential (not incuding the quantity) e.g. s, not kg/s
Example 1: integrate v (dr/dt) with respect to time over constant time spacing during a fixed-time segment Example 2: integrate v / a, a.k.a [(dr/dt) * (dt/dv)] wrt velocity over constant velocity spacing during a segment with known starting and ending velocities