Esempio n. 1
0
    def test_lattice(self):
        # define links and network layout
        N_side = 20
        N = N_side**2
        links = get_2D_lattice_links(N_side,
                                     periodic=True,
                                     diagonal_links=True)
        network = get_grid_layout(N)

        # define model
        R0 = 3
        recovery_rate = 1 / 8
        model = StochasticSIRModel(N,
                                   R0,
                                   recovery_rate,
                                   edge_weight_tuples=links)
        model.set_random_initial_conditions({'I': 20, 'S': N - 20})

        sampling_dt = 2

        visualize(model,
                  network,
                  sampling_dt,
                  config={
                      'draw_nodes_as_rectangles': True,
                      'draw_links': False,
                      'show_legend': False,
                      'show_curves': False,
                  })
Esempio n. 2
0
    def test_grid_well_mixed(self):
        N = 20 * 20
        network = get_grid_layout(N)

        R0 = 3
        recovery_rate = 1 / 8
        model = StochasticSIRModel(N, R0, recovery_rate)
        model.set_random_initial_conditions({'I': 20, 'S': N - 20})

        sampling_dt = 2

        visualize(model,
                  network,
                  sampling_dt,
                  ignore_plot_compartments=['S'],
                  config={
                      'draw_nodes_as_rectangles': True,
                      'show_legend': False,
                  })
Esempio n. 3
0
            return self.u.flatten()
        else:
            return self.v.flatten()


if __name__=="__main__":

    NSide = 200
    N = NSide**2
    Du = 0.16
    Dv = 0.08
    f = 0.060
    k = 0.062

    u, v = get_initial_configuration(NSide,random_influence=0.2)

    dt = 20

    GS = GrayScott(u,v,k,f,Du,Dv,periodic=True,diagonal_links=True)

    network = get_grid_layout(N)

    visualize_reaction_diffusion(GS,
                                 network,
                                 dt,
                                 node_compartments=np.arange(N),
                                 n_integrator_midpoints=20,
                                 value_extent=[0,1],
                                 config={'draw_nodes_as_rectangles':True}
                                 )
Esempio n. 4
0
    NSide = 200
    N = NSide**2
    u, v = get_initial_configuration(NSide,random_influence=0.2)
    Du = 0.16
    Dv = 0.08
    f = 0.060
    k = 0.062

    #DA, DB, f, k = 0.14, 0.06, 0.035, 0.065 # bacteria

    dt = 1
    updates_per_frame = 40
    sampling_dt = updates_per_frame * dt

    GS = GrayScott(u,v,k,f,Du,Dv,periodic=True,diagonal_links=False)

    network = get_grid_layout(N,windowwidth=NSide)

    visualize_reaction_diffusion(GS,
                                 network,
                                 sampling_dt,
                                 node_compartments=np.arange(N),
                                 n_integrator_midpoints=updates_per_frame-1,
                                 #value_extent=[0.35,0.48],
                                 config={'draw_nodes_as_rectangles':True}
                                 )
    #from bfmplot import pl
    #pl.hist(GS.u)
    #pl.show()
Esempio n. 5
0
from epipack.vis import visualize, get_grid_layout
from epipack import get_2D_lattice_links

if __name__ == "__main__":
    import netwulf as nw
    from epipack import StochasticEpiModel
    import networkx as nx

    N_side = 200
    N = N_side * N_side

    links = get_2D_lattice_links(N_side, periodic=True, diagonal_links=True)
    #links = get_2D_lattice_links(N_side,periodic=True,diagonal_links=False)

    network = get_grid_layout(N, links, windowwidth=400)

    k0 = 2 * len(links) / N

    model = StochasticEpiModel(
        list("SIRXTQ"),
        N=N,
        edge_weight_tuples=links,
    )
    Reff = 3
    R0 = 10
    recovery_rate = 1 / 8
    quarantine_rate = 1 / 32
    tracing_rate = 1 / 2
    waning_immunity_rate = 1 / 14
    infection_rate = Reff * (recovery_rate + quarantine_rate) / k0
    infection_rate = R0 * (recovery_rate) / k0