Ejemplo n.º 1
0
def td_hamiltonian(N, E, J, gamma, gammabar, timesteps, dt):
    import numpy as np
    from hamiltonian import get_hamiltonian
    from densitymatrix import get_densitymatrix
    from population import get_population
    from liouville import get_liouvilleoperator

    # Setup Hamiltonian and Initial conditions
    H = get_hamiltonian(N, E, J)
    rho = get_densitymatrix(N)

    # Init population
    pop = np.zeros((timesteps, N))

    # Run in time
    for t in range(timesteps):
        # Calculate population first and normalize
        pop[t, :] = get_population(rho)
        norm = np.sum(pop[t, :])
        rho = rho / norm

        # Calculate rho_dot and update rho
        rho_dot = get_liouvilleoperator(H, rho, gamma, gammabar)
        rho = rho + rho_dot * dt

    return (pop)
import numpy as np
import scipy.integrate
import matplotlib.pyplot as plt
import matplotlib.widgets  # Cursor
import matplotlib.dates
import matplotlib.ticker

import shared
import world_data
import population

COUNTRY = 'Germany'  # e.g. 'all' South Korea' 'France'  'Republic of Korea' 'Italy' 'Germany'  'US' 'Spain'
PROVINCE = 'all'  # 'all' 'Hubei'  # for provinces other than Hubei the population value needs to be set manually
EXCLUDECOUNTRIES = ['China'] if COUNTRY == 'all' else []  # massive measures early on

population = population.get_population(COUNTRY, PROVINCE, EXCLUDECOUNTRIES)

# --- parameters ---

if COUNTRY == 'Germany':
    intensiveUnits = 28000 / 1.5 / 2  # ICU units available  # Germany: 28000  # note that infections might show up in local clusters making things worse
else:
    intensiveUnits = population * 1.0 / 10000  # rough guess for industrialized country

#intensiveUnits = ...  # your country

logPlot = 1

E0 = 1  # exposed at initial time step
daysTotal = 365  # total days to model
dataOffset = 'auto'  # position of real world data relative to model in whole days. 'auto' will choose optimal offset based on matching of deaths curves
Ejemplo n.º 3
0
        cases = int(XCDR_data[-1, 1])  # last row, third column
        deaths = int(XCDR_data[-1, 2])  # last row, third column
        if deaths < 10:
            continue
        recovered = int(XCDR_data[-1, 3])  # last row, third column
        date = XCDR_data[-1, 0]
        countryDeaths.append((country, cases, deaths, recovered, date))

    except Exception as e:
        print("fail: ", country, sys.exc_info()[0], e)

countryDeathsPC = []
for ccdrd in countryDeaths:
    country, cases, deaths, recovered, date = ccdrd
    try:
        pop = population.get_population(country)
        countryDeathsPC.append(
            (country, deaths * 1.0e6 / pop, deaths, pop, date))
        #countryDeathrate.append((country, 100.0 * deaths / cases, deaths, pop))
    except KeyError:
        print("fail: ", country)

print()
countryDeathsPC = sorted(countryDeathsPC,
                         key=lambda x: x[1])  # sort by second subitem
countryDeathsPC.reverse()  # in place

dCountryDeathsPCXY = {}
for country, trash, trash, trash, trash in countryDeathsPC[0:20]:
    province = 'all'
    country2 = country
Ejemplo n.º 4
0
import numpy as np
import scipy.integrate
import matplotlib.pyplot as plt
import matplotlib.widgets  # Cursor

import world_data
import population

COUNTRY = 'Italy'  #South Korea'  #  e.g. 'France'  'Republic of Korea' 'Italy' 'Germany'
PROVINCE = 'all'  #'all'  # 'Hubei'

#populations = {'Germany' : 81E6, 'France' : 67E6, 'Italy' : 61E6, 'Iran' : 81E6,
#'China' : 1438E6, 'Hubei' : 59E6, 'Republic of Korea' : 51E6}

if PROVINCE == 'all':
    population = population.get_population(COUNTRY)
else:
    population = populations[PROVINCE]  # to be implemented

intensiveUnits = 14000 / 2  # ICU units available  # Germany: 28000

logPlot = True

E0 = 1  # exposed at initial time step

days = 165  # total days to model

dataOffset = 25  # how many days will the real world country data be delayed in the model

days0 = dataOffset + 35  # days before lockdown measures