def test_Vector_State1(self): # state is a vector state_list = ['y1:4'] param_list = [] # transitions call from the vector transition_list = [ Transition(origin='y[0]', destination='y[1]', equation='0.04*y[0]', transition_type=TransitionType.T), Transition(origin='y[1]', destination='y[0]', equation='1e4*y[1]*y[2]', transition_type=TransitionType.T), Transition(origin='y[1]', destination='y[2]', equation='3e7*y[1]*y[1]', transition_type=TransitionType.T) ] # initialize the model ode = DeterministicOde(state_list, param_list, transition=transition_list) ode.get_ode_eqn() t = numpy.append(0, 4*numpy.logspace(-6, 6, 1000)) ode.initial_values = ([1.0, 0.0, 0.0], t[0]) # try to integrate to see if there is any problem _solution, _output = ode.integrate(t[1::], full_output=True)
def test_Vector_State3(self): # state is a vector state_list = [ODEVariable('y1', 'y1'), ODEVariable('y2', 's'), ODEVariable('y3', 'x')] param_list = [] # transitions are explicit names transition_list = [ Transition(origin='y1', destination='y2', equation='0.04*y1', transition_type=TransitionType.T), Transition(origin='y2', destination='y1', equation='1e4*y2*y3', transition_type=TransitionType.T), Transition(origin='y2', destination='y3', equation='3e7*y2*y2', transition_type=TransitionType.T) ] ode = DeterministicOde(state_list, param_list, transition=transition_list) ode.get_ode_eqn() t = numpy.append(0, 4*numpy.logspace(-6, 6, 1000)) ode.initial_values = ([1.0, 0.0, 0.0], t[0]) # try to integrate to see if there is any problem solution, output = ode.integrate(t[1::], full_output=True)
def test_deterministic(self): ode = DeterministicOde(self.states, self.params, birth_death=self.birth_deaths, transition=self.transitions) ode.parameters = self.param_eval ode.initial_values = (self.x0, self.t[0]) _solution = ode.integrate(self.t[1::])
) ] # Build the model system model_system = DeterministicOde(states, parameters, transition=transitions, birth_death=births_deaths, derived_param=derived_parameters) model_system.print_ode() # Create the timeline t = numpy.linspace(0, 200, 200) # Set the inital values for the states model_system.initial_values = ([1000000, 20000, 15, 10, 0, 0], t[0]) liberia_parameters = { 'phi_H': 1.6, 'sigma_I': 0.1, 'sigma_H': 0.5, 'theta_I': 0.1, 'theta_H': 0.2, 'alpha': 0.1, 'tau': 0.16, 'Rec_rate': 1.7, 'p': 0.2, 'beta': 0.371, 'mu': (1 / 63) / 365, 'eta': 0.7, }