Derivative Prognostics Model

class prog_models.deriv_prog_model.DerivProgModel(options={})

A Prognostics Model where the first derivative of state can be defined for any time

The DerivProgModel class is a wrapper around a mathematical model of a system as represented by a dx, output, input, and threshold equations. It is a subclass of the Model class, with the addition of a threshold equation, which defines when some condition, such as end-of-life, has been reached.

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’]

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)
abstract dx(t, x, u)

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

Parameters
  • t (number) – Current timestamp in seconds (≥ 0) e.g., t = 3.4

  • 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(3.0, x, u) # Returns first derivative of state at 3 seconds given input u
event_state(t, x) → dict

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

Parameters
  • t (number) – Current timestamp in seconds (≥ 0.0) e.g., t = 3.4

  • 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(3.0, 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)

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

Generate a new prognostics model from 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

  • dx_eqn (callable) – Equation to calculate dx from current state. See dx

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

  • 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 = DerivProgModel.generate_model(keys, initialize_eqn, dx_eqn, output_eqn, event_state_eqn, threshold_eqn)
abstract initialize(u, z) → dict

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(t, x, u, dt)

State transition equation: Calculate next state

Parameters
  • t (number) – Current timestamp in seconds (≥ 0) e.g., t = 3.4

  • 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(3.0, x, u, 0.1) # Returns state at 3.1 seconds given input u
abstract output(t, x) → dict

Calculate next state, forward one timestep

Parameters
  • t (number) – Current timestamp in seconds (≥ 0.0) e.g., t = 3.4

  • 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 inputs = [‘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, options={}) → 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 (dict, optional:) – Configuration options for the simulation Note: configuration of the model is set through model.parameters

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 occurrence, 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, options={}, threshold_keys=None) → tuple

Simulate prognostics model until at least 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)

  • options (dict, optional) – Configuration options for the simulation Note: configuration of the model is set through model.parameters

  • 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 ()

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 occurrence, 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(t, x) → dict

For each event threshold, calculate if it has been met

Parameters
  • t (number) – Current timestamp in seconds (≥ 0.0) e.g., t = 3.4

  • 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(t=3.2, 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