LCOV - code coverage report
Current view: top level - models/ode_seair - model.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 32 32 100.0 %
Date: 2024-11-18 12:45:26 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*
       2             : * Copyright (C) 2020-2024 MEmilio
       3             : *
       4             : * Authors: Ralf Hannemann-Tamas
       5             : *
       6             : * Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
       7             : *
       8             : * Licensed under the Apache License, Version 2.0 (the "License");
       9             : * you may not use this file except in compliance with the License.
      10             : * You may obtain a copy of the License at
      11             : *
      12             : *     http://www.apache.org/licenses/LICENSE-2.0
      13             : *
      14             : * Unless required by applicable law or agreed to in writing, software
      15             : * distributed under the License is distributed on an "AS IS" BASIS,
      16             : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      17             : * See the License for the specific language governing permissions and
      18             : * limitations under the License.
      19             : */
      20             : 
      21             : #ifndef ODESEAIR_MODEL_H
      22             : #define ODESEAIR_MODEL_H
      23             : 
      24             : #include "memilio/compartments/compartmentalmodel.h"
      25             : #include "memilio/config.h"
      26             : #include "memilio/epidemiology/populations.h"
      27             : #include "ode_seair/infection_state.h"
      28             : #include "ode_seair/parameters.h"
      29             : 
      30             : namespace mio
      31             : {
      32             : namespace oseair
      33             : {
      34             : 
      35             : template <typename FP = ScalarType>
      36             : class Model : public mio::CompartmentalModel<FP, InfectionState, mio::Populations<FP, InfectionState>, Parameters<FP>>
      37             : {
      38             :     using Base = mio::CompartmentalModel<FP, InfectionState, mio::Populations<FP, InfectionState>, Parameters<FP>>;
      39             : 
      40             : public:
      41             :     using typename Base::ParameterSet;
      42             :     using typename Base::Populations;
      43             : 
      44          47 :     Model()
      45          47 :         : Base(Populations({InfectionState::Count}, 0.), ParameterSet())
      46             :     {
      47          47 :     }
      48             : 
      49        3810 :     void get_derivatives(Eigen::Ref<const Vector<FP>> pop, Eigen::Ref<const Vector<FP>> y, FP /* t */,
      50             :                          Eigen::Ref<Vector<FP>> dydt) const override
      51             :     {
      52        3810 :         auto& params         = this->parameters;
      53        3810 :         const auto pop_total = pop.sum();
      54             : 
      55        3810 :         dydt[(size_t)InfectionState::Susceptible] =
      56        3822 :             -params.template get<SocialDistancing<FP>>() / pop_total * y[(size_t)InfectionState::Susceptible] *
      57        3834 :                 pop[(size_t)InfectionState::Asymptomatic] -
      58        3822 :             params.template get<Quarantined<FP>>() / pop_total * y[(size_t)InfectionState::Susceptible] *
      59        3834 :                 pop[(size_t)InfectionState::Infected] +
      60        3816 :             params.template get<TimeRecoveredInv<FP>>() * y[(size_t)InfectionState::Recovered];
      61        3810 :         dydt[(size_t)InfectionState::Exposed] =
      62        3822 :             params.template get<SocialDistancing<FP>>() / pop_total * y[(size_t)InfectionState::Susceptible] *
      63        3834 :                 pop[(size_t)InfectionState::Asymptomatic] +
      64        3822 :             params.template get<Quarantined<FP>>() / pop_total * y[(size_t)InfectionState::Susceptible] *
      65        3834 :                 pop[(size_t)InfectionState::Infected] -
      66        3816 :             y[(size_t)InfectionState::Exposed] / params.template get<TimeExposed<FP>>();
      67        3810 :         dydt[(size_t)InfectionState::Asymptomatic] =
      68        3822 :             y[(size_t)InfectionState::Exposed] / params.template get<TimeExposed<FP>>() -
      69        3822 :             (params.template get<TestingRate<FP>>() + params.template get<RecoveryRateFromAsymptomatic<FP>>()) *
      70        3816 :                 y[(size_t)InfectionState::Asymptomatic];
      71        3810 :         dydt[(size_t)InfectionState::Infected] =
      72        3822 :             params.template get<TestingRate<FP>>() * y[(size_t)InfectionState::Asymptomatic] -
      73        3822 :             (params.template get<RecoveryRate<FP>>() + params.template get<DeathRate<FP>>()) *
      74        3816 :                 y[(size_t)InfectionState::Infected];
      75        3810 :         dydt[(size_t)InfectionState::Recovered] =
      76        3822 :             params.template get<RecoveryRateFromAsymptomatic<FP>>() * y[(size_t)InfectionState::Asymptomatic] +
      77        3834 :             params.template get<RecoveryRate<FP>>() * y[(size_t)InfectionState::Infected] -
      78        3816 :             params.template get<TimeRecoveredInv<FP>>() * y[(size_t)InfectionState::Recovered];
      79        3810 :         dydt[(size_t)InfectionState::Dead] = params.template get<DeathRate<FP>>() * y[(size_t)InfectionState::Infected];
      80        3810 :     }
      81             : };
      82             : 
      83             : } // namespace oseair
      84             : } // namespace mio
      85             : 
      86             : #endif // ODESEAIR_MODEL_H

Generated by: LCOV version 1.14