Models

The Prognostics Model Package is distributed with a few pre-constructed models that can be used in simulation or prognostics (with the prog_algs package). These models are summarized in the table below with additional detail in the following sections.

Models Summary

Battery Model - Circuit

Battery Model - Electro Chemistry

Centrifugal Pump

Pneumatic Valve

Events

End of Discharge (EOD)

  • End of Discharge (EOD)

  • InsufficientCapacity

  • Impeller Wear Failure

  • Pump Oil Overheating

  • Radial Bering Overheat

  • Thrust Beiring Overheat

  • Leak-Bottom

  • Leak-Top

  • Leak-Internal

  • Spring Failure

  • Friction Failure

Inputs / Loading

Current (i)

Current (i)

  • Ambient Temperature-K (Tamb)

  • Voltage (V)

  • Discharge Pressure-Pa (pdisch)

  • Suction Pressure-Pa (psuc)

  • Sync Rotational Speed of

  • supply voltage-rad/sec (wsync)

  • Left Pressure-Pa (pL)

  • Right Pressure-Pa (pR)

  • Bottom Port Pressure-Pa (uBot)

  • Top Port Pressure-Pa (uTop)

Outputs / Measurements

Voltage (v), Temp °C (t)

Voltage (v), Temp °C (t)

  • Discharge Flow- m^3/s (Qout)

  • Oil Temp - K (To)

  • Radial Bearing Temp - K (Tr)

  • Thrust Bearing Temp - K (Tt)

  • Mech rotation - rad/s (w)

  • Florrate (Q)

  • Is piston at bottom (iB)

  • Is piston at top (iT)

  • Pressure at bottom - Pa (pB)

  • Pressure at top - Pa (pT)

  • Position of piston - m (x)

Notes

Faster and less accurate than Electro Chem Model

Slower and more accurate than Circuit model

Battery Model - Circuit

class prog_models.models.BatteryCircuit(**kwargs)

Prognostics model for a battery, represented by an electric circuit

This class implements an equivilant circuit model as described in the following paper: M. Daigle and S. Sankararaman, “Advanced Methods for Determining Prediction Uncertainty in Model-Based Prognostics with Application to Planetary Rovers,” Annual Conference of the Prognostics and Health Management Society 2013, pp. 262-274, New Orleans, LA, October 2013. https://papers.phmsociety.org/index.php/phmconf/article/view/2253

Events: (1)

EOD: End of Discharge

Inputs/Loading: (1)

i: Current draw on the battery

States: (4)
tb : Battery Temperature (°C)
qb : Charge stored in Capacitor Cb of the equivalent circuit model
qcp : Charge stored in Capacitor Ccp of the equivalent circuit model
qcs : Charge stored in Capacitor Ccs of the equivalent circuit model
Outputs: (2)
t: Temperature of battery (°C)
v: Voltage supplied by battery
Model Configuration Parameters:
process_noise : Process noise (applied at dx/next_state). Can be number (e.g., .2) applied to every state, a dictionary of values for each state (e.g., {‘x1’: 0.2, ‘x2’: 0.3}), or a function (x) -> x
process_noise_dist : Optional, distribution for process noise (e.g., normal, uniform, triangular)
measurement_noise : Measurement noise (applied in output eqn) Can be number (e.g., .2) applied to every output, a dictionary of values for each output (e.g., {‘z1’: 0.2, ‘z2’: 0.3}), or a function (z) -> z
measurement_noise_dist : Optional, distribution for measurement noise (e.g., normal, uniform, triangular)
V0 : Nominal Battery Voltage
Rp : Battery Parasitic Resistance
qMax : Maximum Charge
CMax : Max Capacity
VEOD : End of Discharge Voltage Threshold
Cb0 : Battery Capacity Parameter
Cbp0 : Battery Capacity Parameter
Cbp1 : Battery Capacity Parameter
Cbp2 : Battery Capacity Parameter
Cbp3 : Battery Capacity Parameter
Rs : R-C Pair Parameter
Cs : R-C Pair Parameter
Rcp0 : R-C Pair Parameter
Rcp1 : R-C Pair Parameter
Rcp2 : R-C Pair Parameter
Ccp : R-C Pair Parameter
Ta : Ambient Temperature
Jt : Temperature parameter
ha : Heat transfer coefficient, ambient
hcp : Heat transfer coefficient parameter
hcs : Heat transfer coefficient - surface
x0 : Initial state

Note: This is much quicker but also less accurate as the electrochemistry model

apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u={}, z={})

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt) dict

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state

Battery Model - Electro Chemistry

prog_models.models.BatteryElectroChem

alias of prog_models.models.battery_electrochem.BatteryElectroChemEODEOL

End of Discharge

class prog_models.models.BatteryElectroChemEOD(**kwargs)

Prognostics model for a battery, represented by an electrochemical equations.

This class implements an Electro chemistry model as described in the following paper: M. Daigle and C. Kulkarni, “Electrochemistry-based Battery Modeling for Prognostics,” Annual Conference of the Prognostics and Health Management Society 2013, pp. 249-261, New Orleans, LA, October 2013. https://papers.phmsociety.org/index.php/phmconf/article/view/2252

The default model parameters included are for Li-ion batteries, specifically 18650-type cells. Experimental discharge curves for these cells can be downloaded from the Prognostics Center of Excellence Data Repository https://ti.arc.nasa.gov/tech/dash/groups/pcoe/prognostic-data-repository/.

Events: (1)

EOD: End of Discharge

Inputs/Loading: (1)

i: Current draw on the battery

States: (8)
tb: Battery temperature (K)
Vo: Voltage Drops due to Solid-Phase Ohmic Resistances
Vsn: Negative Surface Voltage (V)
Vsp: Positive Surface Voltage (V)
qnB: Amount of Negative Ions at the Battery Bulk
qnS: Amount of Negative Ions at the Battery Surface
qpB: Amount of Positive Ions at the Battery Bulk
qpS: Amount of Positive Ions at the Battery Surface
Outputs/Measurements: (2)
t: Temperature of battery (°C)
v: Voltage supplied by battery
Model Configuration Parameters:
process_noise : Process noise (applied at dx/next_state). Can be number (e.g., .2) applied to every state, a dictionary of values for each state (e.g., {‘x1’: 0.2, ‘x2’: 0.3}), or a function (x) -> x
process_noise_dist : Optional, distribution for process noise (e.g., normal, uniform, triangular)
measurement_noise : Measurement noise (applied in output eqn) Can be number (e.g., .2) applied to every output, a dictionary of values for each output (e.g., {‘z1’: 0.2, ‘z2’: 0.3}), or a function (z) -> z
measurement_noise_dist : Optional, distribution for measurement noise (e.g., normal, uniform, triangular)
qMobile :
xnMax : Maximum mole fraction (neg electrode)
xnMin : Minimum mole fraction (neg electrode)
xpMax : Maximum mole fraction (pos electrode)
xpMin : Minimum mole fraction (pos electrode) - note xn + xp = 1
Ro : for Ohmic drop (current collector resistances plus electrolyte resistance plus solid phase resistances at anode and cathode)
alpha : anodic/cathodic electrochemical transfer coefficient
Sn : Surface area (- electrode)
Sp : Surface area (+ electrode)
kn : lumped constant for BV (- electrode)
kp : lumped constant for BV (+ electrode)
Vol : total interior battery volume/2 (for computing concentrations)
VolSFraction : fraction of total volume occupied by surface volume
tDiffusion : diffusion time constant (increasing this causes decrease in diffusion rate)
to : for Ohmic voltage
tsn : for surface overpotential (neg)
tsp : for surface overpotential (pos)
U0p : Redlich-Kister parameter (+ electrode)
Ap : Redlich-Kister parameters (+ electrode)
U0n : Redlich-Kister parameter (- electrode)
An : Redlich-Kister parameters (- electrode)
VEOD : End of Discharge Voltage Threshold
x0 : Initial state
apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u={}, z={})

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt) dict

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state

End of Life (i.e., InsufficientCapacity)

class prog_models.models.BatteryElectroChemEOL(**kwargs)

Prognostics model for a battery degredation, represented by an electrochemical equations.

This class implements an Electro chemistry model as described in the following paper: M. Daigle and C. Kulkarni, “End-of-discharge and End-of-life Prediction in Lithium-ion Batteries with Electrochemistry-based Aging Models,” AIAA SciTech Forum 2016, San Diego, CA. https://arc.aiaa.org/doi/pdf/10.2514/6.2016-2132

The default model parameters included are for Li-ion batteries, specifically 18650-type cells. Experimental discharge curves for these cells can be downloaded from the Prognostics Center of Excellence Data Repository https://ti.arc.nasa.gov/tech/dash/groups/pcoe/prognostic-data-repository/.

Events: (1)

InsufficientCapacity: Insufficient battery capacity

Inputs/Loading: (1)

i: Current draw on the battery

States: (3)
qMax: Maximum battery capacity
Ro : for Ohmic drop (current collector resistances plus electrolyte resistance plus solid phase resistances at anode and cathode)
D : diffusion time constant (increasing this causes decrease in diffusion rate)

Outputs/Measurements: (0)

Model Configuration Parameters:
process_noise : Process noise (applied at dx/next_state). Can be number (e.g., .2) applied to every state, a dictionary of values for each state (e.g., {‘x1’: 0.2, ‘x2’: 0.3}), or a function (x) -> x
process_noise_dist : Optional, distribution for process noise (e.g., normal, uniform, triangular)
measurement_noise : Measurement noise (applied in output eqn) Can be number (e.g., .2) applied to every output, a dictionary of values for each output (e.g., {‘z1’: 0.2, ‘z2’: 0.3}), or a function (z) -> z
measurement_noise_dist : Optional, distribution for measurement noise (e.g., normal, uniform, triangular)
qMaxThreshold : Threshold for qMax (for threshold_met and event_state)
wq, wr, wd : Wear rate for qMax, Ro, and D respectively
x0 : Initial state
apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u={}, z={})

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt) dict

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state

End of Discharge, End of Life (i.e., InsufficientCapacity)

class prog_models.models.BatteryElectroChemEODEOL(**kwargs)

Prognostics model for a battery degredation and discharge, represented by an electrochemical equations.

This class implements an Electro chemistry model as described in the following papers:

  1. M. Daigle and C. Kulkarni, “End-of-discharge and End-of-life Prediction in Lithium-ion Batteries with Electrochemistry-based Aging Models,” AIAA SciTech Forum 2016, San Diego, CA. https://arc.aiaa.org/doi/pdf/10.2514/6.2016-2132

  2. M. Daigle and C. Kulkarni, “Electrochemistry-based Battery Modeling for Prognostics,” Annual Conference of the Prognostics and Health Management Society 2013, pp. 249-261, New Orleans, LA, October 2013. https://papers.phmsociety.org/index.php/phmconf/article/view/2252

The default model parameters included are for Li-ion batteries, specifically 18650-type cells. Experimental discharge curves for these cells can be downloaded from the Prognostics Center of Excellence Data Repository https://ti.arc.nasa.gov/tech/dash/groups/pcoe/prognostic-data-repository/.

Events: (2)
EOD: End of Discharge
InsufficientCapacity: Insufficient battery capacity
Inputs/Loading: (1)

i: Current draw on the battery

States: (11)

See BatteryElectroChemEOD, BatteryElectroChemEOL

Outputs/Measurements: (2)
t: Temperature of battery (°C)
v: Voltage supplied by battery
Model Configuration Parameters:
see: BatteryElectroChemEOD, BatteryElectroChemEOL
apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u={}, z={})

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt) dict

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state

Pump Model

prog_models.models.CentrifugalPump

alias of prog_models.models.centrifugal_pump.CentrifugalPumpWithWear

class prog_models.models.CentrifugalPumpWithWear(**kwargs)

Prognostics model for a centrifugal pump with wear parameters as part of the model state. This is identical to CentrifugalPumpBase, only CentrifugalPumpBase has the wear params as parameters instead of states

This class implements a Centrifugal Pump model as described in the following paper: M. Daigle and K. Goebel, “Model-based Prognostics with Concurrent Damage Progression Processes,” IEEE Transactions on Systems, Man, and Cybernetics: Systems, vol. 43, no. 4, pp. 535-546, May 2013. https://www.researchgate.net/publication/260652495_Model-Based_Prognostics_With_Concurrent_Damage_Progression_Processes

Events (4)

See CentrifugalPumpBase

Inputs/Loading: (5)

See CentrifugalPumpBase

States: (12)
States from CentrifugalPumpBase +
wA: Wear Rate for Impeller Area
wRadial: Wear Rate for Radial (thrust) Friction Coefficient
wRadial: Wear Rate for Rolling Friction Coefficient
Outputs/Measurements: (5)

See CentrifugalPumpBase

Model Configuration Parameters:

See CentrifugalPumpBase

apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u, z=None)

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt)

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state

Pump Model (Base)

class prog_models.models.CentrifugalPumpBase(**kwargs)

Prognostics model for a centrifugal pump

This class implements a Centrifugal Pump model as described in the following paper: M. Daigle and K. Goebel, “Model-based Prognostics with Concurrent Damage Progression Processes,” IEEE Transactions on Systems, Man, and Cybernetics: Systems, vol. 43, no. 4, pp. 535-546, May 2013. https://www.researchgate.net/publication/260652495_Model-Based_Prognostics_With_Concurrent_Damage_Progression_Processes

Events (4)
ImpellerWearFailure: Failure of the impeller due to wear
PumpOilOverheat: Overheat of the pump oil
RadialBearingOverheat: Overheat of the radial bearing
ThrustBearingOverheat: Overhead of the thrust bearing
Inputs/Loading: (5)
Tamb: Ambient Temperature (K)
V: Voltage
pdisch: Discharge Pressure (Pa)
psuc: Suction Pressure (Pa)
wsync: Syncronous Rotational Speed of Supply Voltage (rad/sec)
States: (9)
A: Impeller Area (m^2)
Q: Flow Rate into Pump (m^3/s)
To: Oil Temperature (K)
Tr: Radial Bearing Temperature (K)
Tt: Thrust Bearing Temperature (K)
rRadial: Radial (thrust) Friction Coefficient
rThrust: Rolling Friction Coefficient
w: Rotational Velocity of Pump (rad/sec)
QLeak: Leak Flow Rate (m^3/s)
Outputs/Measurements: (5)
Qout: Discharge Flow (m^3/s)
To: Oil Temperature (K)
Tr: Radial Bearing Temperature (K)
Tt: Thrust Bearing Temperature (K)
w: Rotational Velocity of Pump (rad/sec)
Model Configuration Parameters:
process_noise : Process noise (applied at dx/next_state). Can be number (e.g., .2) applied to every state, a dictionary of values for each state (e.g., {‘x1’: 0.2, ‘x2’: 0.3}), or a function (x) -> x
process_noise_dist : Optional, distribution for process noise (e.g., normal, uniform, triangular)
measurement_noise : Measurement noise (applied in output eqn) Can be number (e.g., .2) applied to every output, a dictionary of values for each output (e.g., {‘z1’: 0.2, ‘z2’: 0.3}), or a function (z) -> z
measurement_noise_dist : Optional, distribution for measurement noise (e.g., normal, uniform, triangular)
pAtm : Atmospheric pressure
a0, a1, a2 : empirical coefficients for flow torque eqn
A : impeller blade area
b :
n : Pole Phases
p : Pole Pairs
I : impeller/shaft/motor lumped inertia
r : lumped friction parameter (minus bearing friction)
R1, R2 :
L1 :
FluidI: Pump fluid inertia
c : Pump flow coefficient
cLeak : Internal leak flow coefficient
ALeak : Internal leak area
mcThrust :
HThrust1, HThrust2 :
mcRadial :
HRadial1, HRadial2 :
mcOil :
HOil1, HOil2, HOil3 :
wA, wRadial, wThrust : Wear rates. See also CentrifugalPumpWithWear
lim : Parameter limits (dict)
x0 : Initial state
apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u, z=None)

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt)

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state

Pneumatic Valve

prog_models.models.PneumaticValve

alias of prog_models.models.pneumatic_valve.PneumaticValveWithWear

class prog_models.models.PneumaticValveWithWear(**kwargs)

Prognostics model for a pneumatic valve with wear parameters as part of the model state. This is identical to PneumaticValveBase, only PneumaticValveBase has the wear params as parameters instead of states

This class implements a Pneumatic Valve model as described in the following paper: M. Daigle and K. Goebel, “A Model-based Prognostics Approach Applied to Pneumatic Valves,” International Journal of Prognostics and Health Management, vol. 2, no. 2, August 2011. https://www.phmsociety.org/node/602

Events (4)

See PneumaticValveBase

Inputs/Loading: (5)

See PneumaticValveBase

States: (12)

States from PneumaticValveBase + wb, wi, wk, wr, wt

Outputs/Measurements: (5)

See PneumaticValveBase

Model Configuration Parameters:

See PneumaticValveBase

apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u, z=None)

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt)

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state

Pneumatic Valve (Base)

class prog_models.models.PneumaticValveBase(**kwargs)

Prognostics model for a pneumatic valve.

This class implements a Pneumatic Valve model as described in the following paper: M. Daigle and K. Goebel, “A Model-based Prognostics Approach Applied to Pneumatic Valves,” International Journal of Prognostics and Health Management, vol. 2, no. 2, August 2011. https://papers.phmsociety.org/index.php/ijphm/article/view/1359

Events: (5)
Bottom Leak: Failure due to a leak at the bottom pneumatic port
Top Leak: Failure due to a leak at the top pneumatic port
Internal Leak: Failure due to an internal leak at the seal surrounding the piston
Spring Failure: Failure due to spring weakening with use
Friction Failure: Failure due to increase in friction along the piston with wear
Inputs/Loading:
pL: Fluid pressure at the left side of the plug (Pa)
pR: Fluid pressure at the right side of the plug (Pa)
uBot: input pressure at the bottom pneumatic port (Pa)
uTop: input pressure at the botton pneumatic port (Pa)
States:
Aeb: Area of the leak at the bottom pneumatic port
Aet: Area of the leak at the top pneumatic port
Ai: Area of the internal leak
k: Spring Coefficient
mBot: Mass on bottom of piston (kg)
mTop: Mass on top of the piston (kg)
r: Friction Coefficient
v: Velocity of the piston (m/s)
x: Poisition of the piston (m)
pDiff: Difference in pressure between the left and the right
Outputs/Measurements:
Q: Flowrate
iB: Is the piston at the bottom (bool)
iT: Is the piston at the top (bool)
pB: Pressure at the bottom (Pa)
pT: Pressure at the top (Pa)
x: Position of piston (m)
Model Configuration Parameters:
process_noise : Process noise (applied at dx/next_state). Can be number (e.g., .2) applied to every state, a dictionary of values for each state (e.g., {‘x1’: 0.2, ‘x2’: 0.3}), or a function (x) -> x
process_noise_dist : Optional, distribution for process noise (e.g., normal, uniform, triangular)
measurement_noise : Measurement noise (applied in output eqn) Can be number (e.g., .2) applied to every output, a dictionary of values for each output (e.g., {‘z1’: 0.2, ‘z2’: 0.3}), or a function (z) -> z
measurement_noise_dist : Optional, distribution for measurement noise (e.g., normal, uniform, triangular)
g : Acceleration due to gravity (m/s^2)
pAtm : Atmospheric pressure (Pa)
m : Plug mass (kg)
offsetX : Spring offset distance (m)
Ls : Stroke Length (m)
Ap : Surface area of piston for gas contact (m^2)
Vbot0 : Below piston “default” volume (m^3)
Vtop0 : Above piston “default” volume (m^3)
indicatorTol : tolerance bound for open/close indicators
pSupply : Supply Pressure (Pa)
Av : Surface area of plug end (m^2)
Cv : flow coefficient assuming Cv of 1300 GPM
rhoL : density of LH2 in kg/m^3
gas_mass : Molar mass of used gas (kg/mol)
gas_temp : temperature of used gas (K)
gas_gamma :
gas_z :
gas_R :
At :
Ct :
Ab :
Cb :
AbMax : Max limit for state Aeb
AtMax : Max limit for state Aet
AiMax : Max limit for state Ai
kMin : Min limit for state k
rMax : Max limit for state r
x0 : Initial state
wb: Wear parameter for bottom leak
wi: Wear parameter for internal leak
wt: Wear parameter for top leak
wk: Wear parameter for spring
wr: Wear parameter for friction
apply_measurement_noise(z) dict

Apply measurement noise to the measurement

Parameters

z (dict) –

output, with keys defined by model.outputs

e.g., z = {‘abc’: 332.1, ‘def’: 221.003} given outputs = [‘abc’, ‘def’]

Returns

z – output, with applied noise, with keys defined by model.outputs

e.g., z = {‘abc’: 332.2, ‘def’: 221.043} given outputs = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
z = {‘z1’: 2.2}
z = m.apply_measurement_noise(z)

Note

Configured using parameters measurement_noise and measurement_noise_dist

apply_process_noise(x, dt=1) dict

Apply process noise to the state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • dt (Number, optional) – Time step (e.g., dt = 0.1)

Returns

x – state, with applied noise, with keys defined by model.states e.g., x = {‘abc’: 332.2, ‘def’: 221.043} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.apply_process_noise(x)

Note

Configured using parameters process_noise and process_noise_dist

calc_error(times, inputs, outputs, **kwargs)

Calculate error between simulated and observed

Parameters
  • times ([double]) – array of times for each sample

  • inputs ([dict]) – array of input dictionaries where input[x] corresponds to time[x]

  • outputs ([dict]) – array of output dictionaries where output[x] corresponds to time[x]

  • kwargs

    Configuration parameters, such as:

    dt [double] : time step

Returns

Total error

Return type

double

dx(x, u)

Calculate the first derivative of state x at a specific time t, given state and input

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

Returns

dx – First derivitive of state, with keys defined by model.states

e.g., dx = {‘abc’: 3.1, ‘def’: -2.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = DerivProgModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
dx = m.dx(x, u) # Returns first derivative of state given input u

See also

next_state

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

estimate_params(runs, keys, **kwargs)

Estimate the model parameters given data. Overrides model parameters

Parameters
  • runs (array[tuple]) – data from all runs, where runs[0] is the data from run 0. Each run consists of a tuple of arrays of times, input dicts, and output dicts

  • keys ([string]) – Parameter keys to optimize

  • kwargs

    Configuration parameters. Supported parameters include:

    method: Optimization method- see scikit.optimize.minimize
    options: Options passed to optimizer

See: examples.param_est

event_state(x)

Calculate event states (i.e., measures of progress towards event (0-1, where 0 means event has occured))

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

event_state – Event States, with keys defined by prognostics_model.events.

e.g., event_state = {‘EOL’:0.32} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
event_state = m.event_state(x) # Returns {‘e1’: 0.8, ‘e2’: 0.6}

Note

Default is to return an empty array (for system models that do not include any events)

See also

threshold_met

static generate_model(keys, initialize_eqn, output_eqn, next_state_eqn=None, dx_eqn=None, event_state_eqn=None, threshold_eqn=None, config={'process_noise': 0.1})

Generate a new prognostics model from individual model functions

Parameters
  • keys (dict) – Dictionary containing keys required by model. Must include inputs, outputs, and states. Can also include events

  • initialize_eqn (callable) – Equation to initialize first state of the model. See initialize

  • output_eqn (callable) – Equation to calculate the outputs (measurements) for the model. See output

  • next_state_eqn (callable) –

    Equation to calculate next_state from current state. See next_state.

    Use this for discrete functions

  • dx_eqn (callable) –

    Equation to calculate dx from current state. See dx.

    Use this for continuous functions

  • event_state_eqn (callable, optional) – Equation to calculate the state for each event of the model. See event_state

  • threshold_eqn (callable, optional) – Equation to calculate if the threshold has been met for each event in model. See threshold_met

  • config (dict, optional) – Any configuration parameters for the model

Returns

model – A callable PrognosticsModel

Return type

PrognosticsModel

Raises

ProgModelInputException

Example

keys = {
‘inputs’: [‘u1’, ‘u2’],
‘states’: [‘x1’, ‘x2’, ‘x3’],
‘outputs’: [‘z1’],
‘events’: [‘e1’, ‘e2’]
}

m = PrognosticsModel.generate_model(keys, initialize_eqn, next_state_eqn, output_eqn, event_state_eqn, threshold_eqn)
initialize(u, z=None)

Calculate initial state given inputs and outputs

Parameters
  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • z (dict) –

    Outputs, with keys defined by model.outputs

    e.g., z = {‘t’:12.4, ‘v’:3.3} given inputs = [‘t’, ‘v’]

Returns

x – First state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
next_state(x, u, dt)

State transition equation: Calculate next state

Parameters
  • x (dict) –

    state, with keys defined by model.states

    e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

  • u (dict) –

    Inputs, with keys defined by model.inputs

    e.g., u = {‘i’:3.2} given inputs = [‘i’]

  • dt (number) –

    Timestep size in seconds (≥ 0)

    e.g., dt = 0.1

Returns

x – Next state, with keys defined by model.states e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
x = m.next_state(x, u, 0.1) # Returns state at 3.1 seconds given input u

See also

dx

Note

A model should overwrite either next_state or dx. Override dx for continuous models, and next_state for discrete, where the behavior cannot be described by the first derivative

observables(x) dict

Calculate observables where

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

obs – Observables, with keys defined by model.observables.

e.g., obs = {‘tMax’:33, ‘iMax’:19} given observables = [‘tMax’, ‘iMax’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
obs = m.observables(3.0, x) # Returns {‘tMax’:33, ‘iMax’:19}
output(x)

Calculate next state, forward one timestep

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

z – Outputs, with keys defined by model.outputs.

e.g., z = {‘t’:12.4, ‘v’:3.3} given outputs = [‘t’, ‘v’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
z = m.output(3.0, x) # Returns {‘o1’: 1.2}
simulate_to(time, future_loading_eqn, first_output, **kwargs) tuple

Simulate prognostics model for a given number of seconds

Parameters
  • time (number) –

    Time to which the model will be simulated in seconds (≥ 0.0)

    e.g., time = 200

  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • options (kwargs, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters

    Supported parameters: see simulate_to_threshold

Returns

  • times (number) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to(200, future_load_eqn, first_output)
simulate_to_threshold(future_loading_eqn, first_output, threshold_keys=None, **kwargs) tuple

Simulate prognostics model until any or specified threshold(s) have been met

Parameters
  • future_loading_eqn (callable) – Function of (t) -> z used to predict future loading (output) at a given time (t)

  • first_output (dict) – First measured output, needed to initialize state

  • threshold_keys ([str], optional) – Keys for events that will trigger the end of simulation. If blank, simulation will occur if any event will be met ()

  • options (keyword arguments, optional) –

    Configuration options for the simulation

    Note: configuration of the model is set through model.parameters.

    Supported parameters:

    • dt (Number0: time step (s), e.g. {‘dt’: 0.1}

    • save_freq (Number): Frequency at which output is saved (s), e.g., save_freq = 10

    • save_pts ([Number]): Additional ordered list of custom times where output is saved (s), e.g., save_pts= [50, 75]

    • horizon (Number): maximum time that the model will be simulated forward (s), e.g., horizon = 1000

    • x (dict): optional, initial state dict, e.g., x= {‘x1’: 10, ‘x2’: -5.3}

    • thresholds_met_eqn (function/lambda): optional, custom equation to indicate logic for when to stop sim f(thresholds_met) -> bool

    • print_inter (bool): optional, toggle intermediate printing, e.g., print_inter = True

    e.g., m.simulate_to_threshold(eqn, z, dt=0.1, save_pts=[1, 2])

Returns

  • times ([number]) – Times for each simulated point

  • inputs ([dict]) – Future input (from future_loading_eqn) for each time in times

  • states ([dict]) – Estimated states for each time in times

  • outputs ([dict]) – Estimated outputs for each time in times

  • event_states ([dict]) – Estimated event state (e.g., SOH), between 1-0 where 0 is event occurance, for each time in times

Raises

ProgModelInputException

See also

simulate_to

Example

def future_load_eqn(t):
if t< 5.0: # Load is 3.0 for first 5 seconds
return 3.0
else:
return 5.0
first_output = {‘o1’: 3.2, ‘o2’: 1.2}
m = PrognosticsModel() # Replace with specific model being simulated
(times, inputs, states, outputs, event_states) = m.simulate_to_threshold(future_load_eqn, first_output)
threshold_met(x)

For each event threshold, calculate if it has been met

Parameters

x (dict) –

state, with keys defined by model.states

e.g., x = {‘abc’: 332.1, ‘def’: 221.003} given states = [‘abc’, ‘def’]

Returns

thresholds_met – If each threshold has been met (bool), with deys defined by prognostics_model.events

e.g., thresholds_met = {‘EOL’: False} given events = [‘EOL’]

Return type

dict

Example

m = PrognosticsModel() # Replace with specific model being simulated
u = {‘u1’: 3.2}
z = {‘z1’: 2.2}
x = m.initialize(u, z) # Initialize first state
threshold_met = m.threshold_met(x) # returns {‘e1’: False, ‘e2’: False}

Note

If not overwritten, the default behavior is to say the threshold is met if the event state is <= 0

See also

event_state