def test_force_model(force_scale_factor, Km, tau_1, tau_2):
    if not isinstance(force_scale_factor, numbers.Number) or not isinstance(Km, numbers.Number) \
            or not isinstance(tau_1, numbers.Number) or not isinstance(tau_2, numbers.Number):
        with pytest.raises(TypeError):
            ForceModel(force_scale_factor, Km, tau_1, tau_2)
    elif force_scale_factor < 0 or Km < 0 or tau_1 < 0 or tau_2 <= 0:
        with pytest.raises(Exception):
            ForceModel(force_scale_factor, Km, tau_1, tau_2)
예제 #2
0
import pytest
import numbers
from model.force_model import ForceModel
from model.fatigue_model import dynamics


@pytest.mark.parametrize("t, Y, force_model, tau_fat, alpha_scale_factor, "
                         "alpha_Km, alpha_tau_1, train, tau_c, result", [
                             (1, [1, 1, 1, 1, 1], ForceModel(
                                 1, 2, 1, 1), 1, 1, 1, 1, [1], 1, [1, 2, 1]),
                             (1, [1, 1, 1, 1], ForceModel(
                                 1, 2, 1, 1), 1, 1, 1, 1, [1], 1, [1, 1, 1]),
                             (1, [1, 1, 1, 1, 1], ForceModel(
                                 1, 2, 1, 1), -1, 1, 1, 1, [1], 1, [1, 1, 1]),
                             ("1", ["1", 1, 1, 1, 1], ForceModel(1, 2, 1, 1),
                              "1", "1", 1, "1", [1], "1", [1, 1, 1]),
                         ])
def test_dynamics(t, Y, force_model, tau_fat, alpha_scale_factor, alpha_Km,
                  alpha_tau_1, train, tau_c, result):
    if not isinstance(t, numbers.Number) or not isinstance(tau_fat, numbers.Number) \
            or not isinstance(alpha_scale_factor, numbers.Number) or not isinstance(alpha_Km, numbers.Number) \
            or not isinstance(alpha_tau_1, numbers.Number) or not isinstance(tau_c, numbers.Number) \
            or not hasattr(Y, '__len__'):
        with pytest.raises(TypeError):
            dynamics(t, Y, force_model, tau_fat, alpha_scale_factor, alpha_Km,
                     alpha_tau_1, train, tau_c)
    elif len(Y) != 5 or tau_fat < 0:
        with pytest.raises(Exception):
            dynamics(t, Y, force_model, tau_fat, alpha_scale_factor, alpha_Km,
                     alpha_tau_1, train, tau_c)
    else:
예제 #3
0
import os
from scipy.integrate import cumulative_trapezoid, simps

CONFIG_PATH = 'configuration/vft_cft33_configuration.csv'

config = load_model_configuration(CONFIG_PATH)
tau_c, tau_2, tau_fat, alpha_scale_factor, alpha_Km, alpha_tau_1, \
CN0, F0, scale_factor_rest, tau_1_rest, Km_rest = config.values()
CONFIG_PATH = 'dft155_configuration.csv'

config = load_model_configuration(CONFIG_PATH)
tau_c, tau_2, tau_fat, alpha_scale_factor, alpha_Km, alpha_tau_1, \
CN0, F0, scale_factor_rest, tau_1_rest, Km_rest = config.values()

total_time = (0, 60 * 1000)
force_model = ForceModel(scale_factor_rest, Km_rest, tau_1_rest, tau_2)
initial_state = [CN0, F0, scale_factor_rest, Km_rest, tau_1_rest]

simulation_trains = [0, 0, 0, 0, 0, 0, 0, 0, 0]

simulation_trains[0] = generate_constant_train(20, 10 * 1000)
simulation_trains[1] = generate_constant_train(50, 10 * 1000)
simulation_trains[2] = generate_constant_train(80, 10 * 1000)
simulation_trains[3] = generate_variable_train(20, 10 * 1000)
simulation_trains[4] = generate_variable_train(50, 10 * 1000)
simulation_trains[5] = generate_variable_train(80, 10 * 1000)
simulation_trains[6] = generate_doublet_train(20, 10 * 1000)
simulation_trains[7] = generate_doublet_train(50, 10 * 1000)
simulation_trains[8] = generate_doublet_train(80, 10 * 1000)

for i in range(9):
def force_model():
    """Returns a ForceModel object"""
    return ForceModel(1, 2, 1, 1)