Answered step by step
Verified Expert Solution
Question
1 Approved Answer
code provided: def modelA(G,x=0,i0=0.1,beta=1.0,gamma=1.0,tf=5,Nt=1000): Simulate model A Input: G: Networkx graph x: node which is initially infected with i_x=i0 i0: magnitude of initial condition
code provided:
def modelA(G,x=0,i0=0.1,beta=1.0,gamma=1.0,tf=5,Nt=1000): """ Simulate model A Input: G: Networkx graph x: node which is initially infected with i_x=i0 i0: magnitude of initial condition beta,gamma: model parameters tf,Nt: Solutions are computed at Nt time steps from t=0 to t=tf (see code below) Output: iarray: N x Nt+1 Array containing i across network nodes at each time step. """ N = G.number_of_nodes() iarray = np.zeros((N,Nt+1)) tarray = np.linspace(0,tf,Nt+1) #Add code here def RHS(y,t): """Compute RHS of modelA at time t input: y should be a size N array output: dy, also a size N array corresponding to dy/dt Discussion: add discussion here """ dy = 0 #modify return dy #Add code here return iarray2. (5 pts) Consider the following two models for transport processes on graphs: Model A: dij N-1 = -Bi; + Ajkik (1 i;) le= 0 Model B: dt = i; and = Salik (Sk 8;) Here, Lik is the Laplacian matrix and Ajk is the adjacency matrix for an N-node graph. i) Complete modelA so that it computes simulations of modelA on the NetworkX graph provided as input. Complete the function, RHS, so that it computes and returns the right-hand side of the model equations (see the function docstring). You should assume that RHS will be called a very large number of times within one call to model A and construct your code accordingly. Construct an estimate of the number of operations required to compute di;/dt, j = 0, ...,N 1 in one call to RHS. Add this estimate to your pdf along with a concise explanation of how it was constructed. Add the needed code below RHS to simulate the model for Nt time steps from t=o to t=tf with the initial condition i = io at node x with x and io provided as input, and finally return ij(t). 2. (5 pts) Consider the following two models for transport processes on graphs: Model A: dij N-1 = -Bi; + Ajkik (1 i;) le= 0 Model B: dt = i; and = Salik (Sk 8;) Here, Lik is the Laplacian matrix and Ajk is the adjacency matrix for an N-node graph. i) Complete modelA so that it computes simulations of modelA on the NetworkX graph provided as input. Complete the function, RHS, so that it computes and returns the right-hand side of the model equations (see the function docstring). You should assume that RHS will be called a very large number of times within one call to model A and construct your code accordingly. Construct an estimate of the number of operations required to compute di;/dt, j = 0, ...,N 1 in one call to RHS. Add this estimate to your pdf along with a concise explanation of how it was constructed. Add the needed code below RHS to simulate the model for Nt time steps from t=o to t=tf with the initial condition i = io at node x with x and io provided as input, and finally return ij(t)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started