<jupyter_start><jupyter_text><NAME>, HIV Model<jupyter_code># Configure Jupyter so figures appear in the notebook
%matplotlib inline

# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'

# import functions from the modsim library
from modsim import *
init = State(R=200, L=0, E=0, V=0.0000004)
gamma = 1.36
tau = 0.2
mu = 0.00136
beta = 0.00027 #per virion?
alpha = 0.036
delta = 0.33
pi = 100
sigma = 2
prop = 0.1
dt = 0.1
def dR(state):
    deriv = (gamma*tau-mu*state.R-beta*state.R*state.V)*dt
    return deriv
def dL(state):
    deriv = (prop*beta*state.R*state.V-mu*state.L-alpha*state.L)*dt
    return deriv
def dE(state):
    deriv = ((1-prop)*beta*state.R*state.V+alpha*state.L-delta*state.E)*dt
    return deriv
def dV(state):
    deriv = (pi*state.E-sigma*state.V)*dt
    return deriv
system = System(dR=dR, dL=dL, dE=dE, dV=dV, t0=0, t_end=100)
def update_func(state, t, system):
    R= dR(state)
    L= dL(state)
    E= dE(state)
    V= dV(state)
    state.R += R
    state.L+=L
    state.E+=E
    state.V+=V
    return state
def run_simulation(state, system, update_func):
    """Runs a simulation of the system.
        
    system: System object
    update_func: function that updates state
    
    returns: TimeFrame
    """
    frame = TimeFrame(columns=state.index)
    frame.row[system.t0] = state
    
    for t in linrange(system.t0, system.t_end, dt):
        frame.row[t+dt] = update_func(frame.row[t], t, system)
    
    return frame
def plot_results(w,x,y,z):
   
    plot(w, '--', label='R')
    plot(x, '-', label='L')
    plot(y, '--', label='E')
    plot(z, '-', label='V')
    decorate(xlabel='Time (Days)',
             ylabel='Cell population')
results = run_simulation(init, system, update_func)
plot_results(results.R,results.L,results.E, results.V)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14758403361344538, 'fraction_numerical': 0.027836134453781514, 'mean_word_length': 3.50354609929078, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '518192', 'license': 'MIT', 'n_tokens_mistral': 761, 'n_tokens_neox': 725, 'n_words': 167, 'path': 'code/HIVmodel.ipynb', 'repo_name': 'erielw/ModSimPy', 'size': '1910'}