def non_physical_behavior(I, a, T, dt, theta): """ Given lists/arrays a and dt, and numbers I, dt, and theta, make a two-dimensional contour line B=0.5, where B=1>0.5 means oscillatory (unstable) solution, and B=0<0.5 means monotone solution of u'=-au. """ a = np.asarray(a) dt = np.asarray(dt) # must be arrays B = np.zeros((len(a), len(dt))) # results for i in range(len(a)): for j in range(len(dt)): u, t = solver(I, a[i], T, dt[j], theta) # Does u have the right monotone decay properties? correct_qualitative_behavior = True for n in range(1, len(u)): if u[n] > u[n - 1]: # Not decaying? correct_qualitative_behavior = False break # Jump out of loop B[i, j] = float(correct_qualitative_behavior) a_, dt_ = st.ndgrid(a, dt) # make mesh of a and dt values st.contour(a_, dt_, B, 1) st.grid('on') st.title('theta=%g' % theta) st.xlabel('a') st.ylabel('dt') st.savefig('osc_region_theta_%s.png' % theta) st.savefig('osc_region_theta_%s.eps' % theta)
def non_physical_behavior(I, a, T, dt, theta): """ Given lists/arrays a and dt, and numbers I, dt, and theta, make a two-dimensional contour line B=0.5, where B=1>0.5 means oscillatory (unstable) solution, and B=0<0.5 means monotone solution of u'=-au. """ a = np.asarray(a); dt = np.asarray(dt) # must be arrays B = np.zeros((len(a), len(dt))) # results for i in range(len(a)): for j in range(len(dt)): u, t = solver(I, a[i], T, dt[j], theta) # Does u have the right monotone decay properties? correct_qualitative_behavior = True for n in range(1, len(u)): if u[n] > u[n-1]: # Not decaying? correct_qualitative_behavior = False break # Jump out of loop B[i,j] = float(correct_qualitative_behavior) a_, dt_ = st.ndgrid(a, dt) # make mesh of a and dt values st.contour(a_, dt_, B, 1) st.grid('on') st.title('theta=%g' % theta) st.xlabel('a'); st.ylabel('dt') st.savefig('osc_region_theta_%s.png' % theta) st.savefig('osc_region_theta_%s.eps' % theta)
def solve(self): from dc_mod import solver self.u, self.t = solver( self.problem.I, self.problem.a, self.problem.T, self.dt, self.theta)
def solve(self): from dc_mod import solver self.u, self.t = solver(self.problem.I, self.problem.a, self.problem.T, self.dt, self.theta)