def A_local_model_balflux(x,lamda,s,p): """ Balanced flux Evans matrix for the system named local_model. """ # wave speed spd = p['spd'] # parameters v_neg = p['v_neg'] tau_neg = p['tau_neg'] S_neg = p['S_neg'] m1 = p['m1'] none = p['none'] mu = p['mu'] kappa = p['kappa'] # interpolate profile solution temp = soln(x,s) #profile values tau = temp[0] S = temp[1] ynot = np.array([tau,S]) temp2 = F_local_model(x,ynot,s,p); tau_x = temp2[0] S_x = temp2[1] v = v_neg - spd * (tau - tau_neg) v_x = -spd * tau_x T_x = S_x * np.exp(S) / tau - np.exp(S) / tau ** 2 * tau_x # Evans matrix out = np.array([ [ lamda / spd, 0, 0, -0.1e1 / spd, 0 ], [ 0, 0, 0, 1, 0 ], [ lamda * (-np.exp(S) / tau ** 2 + tau - (np.exp(S) / tau + 0.1e1) / tau) / spd, 0, 0, -(-np.exp(S) / tau ** 2 + tau - (np.exp(S) / tau + 0.1e1) / tau) / spd + v, (np.exp(S) / tau + 0.1e1) / np.exp(S) * tau ], [ lamda * tau / mu * (v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) / spd, lamda * tau / mu, 0, -tau / mu * ((v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) / spd + spd), 0.1e1 / mu], [ lamda * (-v * tau / kappa * (v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) + tau / kappa * (-spd * (-np.exp(S) / tau ** 2 + tau - (np.exp(S) / tau + 0.1e1) / tau) + v_x * mu * v / tau ** 2 + T_x * kappa / tau ** 2 + v * (-0.3e1 * np.exp(S) / tau ** 3 - 0.1e1))) / spd, -lamda * v * tau / kappa, lamda * tau / kappa, v * tau / kappa * ((v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) / spd + spd) - tau / kappa * ((-spd * (-np.exp(S) / tau ** 2 + tau - (np.exp(S) / tau + 0.1e1) / tau) + v_x * mu * v / tau ** 2 + T_x * kappa / tau ** 2 + v * (-0.3e1 * np.exp(S) / tau ** 3 - 0.1e1)) / spd + spd * v + v_x * mu / tau - np.exp(S) / tau ** 2 + tau), -v / kappa - tau / kappa * (spd * (np.exp(S) / tau + 0.1e1) / np.exp(S) * tau - v / tau) ] ]) return out
def A_k(x,lam,s,p): y = soln([x],sol) y = y[0] Ux = profile_ode(x,y,sol,p) f = 2*y[0]-1-p['Gamma']*p['e_minus'] g = (p['Gamma']*y[1]-(p['nu']+1)*Ux[0])/p['nu'] a21 = lam*y[0]/p['nu'] a22 = y[0]/p['nu'] a23 = y[0]*Ux[0]/p['nu'] - f*Ux[0] - p['Gamma']*Ux[1] # Is the second half correct for U_x_x a24 = lam*g a25 = g+Ux[1]/y[0]; a53 = lam*y[0]+p['Gamma']*Ux[0]; a55 = f-lam; out = np.array([[a22, a23, a24, a25, 0, 0, 0, 0, 0, 0], [0, 0, lam, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [p['Gamma'], a53, lam*y[0], a55, 0, 0, 1, 0, 0, 0], [0, a21, 0, 0, a22, lam, 1, -a24, -a25, 0], [0, 0, a21, 0, 0, a22, 1, a23, 0, -a25], [0, 0, 0, a21, a53, lam*y[0], a22 + a55, 0, a23, a24], [0, 0, 0, 0, 0, 0, 0, 0, 1, -1], [0, 0, 0, 0, -p['Gamma'], 0, 0, lam*y[0], a55, lam], [0, 0, 0, 0, 0, -p['Gamma'], 0, -a53, 0, a55]]) return out
def A_k(x, lam, s, p): y = soln([x], sol) y = y[0] Ux = profile_ode(x, y, sol, p) f = 2 * y[0] - 1 - p['Gamma'] * p['e_minus'] g = (p['Gamma'] * y[1] - (p['nu'] + 1) * Ux[0]) / p['nu'] a21 = lam * y[0] / p['nu'] a22 = y[0] / p['nu'] a23 = y[0] * Ux[0] / p['nu'] - f * Ux[0] - p['Gamma'] * Ux[ 1] # Is the second half correct for U_x_x a24 = lam * g a25 = g + Ux[1] / y[0] a53 = lam * y[0] + p['Gamma'] * Ux[0] a55 = f - lam out = np.array([[a22, a23, a24, a25, 0, 0, 0, 0, 0, 0], [0, 0, lam, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [p['Gamma'], a53, lam * y[0], a55, 0, 0, 1, 0, 0, 0], [0, a21, 0, 0, a22, lam, 1, -a24, -a25, 0], [0, 0, a21, 0, 0, a22, 1, a23, 0, -a25], [0, 0, 0, a21, a53, lam * y[0], a22 + a55, 0, a23, a24], [0, 0, 0, 0, 0, 0, 0, 0, 1, -1], [0, 0, 0, 0, -p['Gamma'], 0, 0, lam * y[0], a55, lam], [0, 0, 0, 0, 0, -p['Gamma'], 0, -a53, 0, a55]]) return out
def A_stable_model_balflux(x,lamda,s,p): # Balanced flux Evans matrix for the system named stable_model. #print("entering A_stable_model_balflux") # wave speed spd = p['spd'] # parameters v_neg = p['v_neg'] tau_neg = p['tau_neg'] S_neg = p['S_neg'] m1 = p['m1'] none = p['none'] mu = p['mu'] kappa = p['kappa'] if s['solve'] == 'bvp': # interpolate profile solution temp = stablab.soln(x,s) else: temp = stablab.deval(x,s.sol) #profile values tau = temp[0] S = temp[1] ynot = np.array([tau,S]) temp2 = F_stable_model(x,ynot,s,p) tau_x = temp2[0] S_x = temp2[1] v = v_neg - spd * (tau - tau_neg) v_x = -spd * tau_x T_x = S_x * np.exp(S) / tau - np.exp(S) / tau ** 2 * tau_x # Evans matrix -- 5 x 5 out = np.array([ [lamda / spd, 0, 0, -0.1e1 / spd, 0], [0, 0, 0, 1, 0], [lamda * (-0.2e1 * np.exp(S) / tau ** 2 + tau) / spd, 0, 0, -(-0.2e1 * np.exp(S) / tau ** 2 + tau) / spd + v, 1 ], [lamda * tau / mu * (v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) / spd, lamda * tau / mu, 0, -tau / mu * ((v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) / spd + spd), 0.1e1 / mu], [lamda * (-v * tau / kappa * (v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) + tau / kappa * (-spd * (-0.2e1 * np.exp(S) / tau ** 2 + tau) + v_x * mu * v / tau ** 2 + T_x * kappa / tau ** 2 + v * (-0.3e1 * np.exp(S) / tau ** 3 - 0.1e1))) / spd, -lamda * v * tau / kappa, lamda * tau / kappa, v * tau / kappa * ((v_x * mu / tau ** 2 - 0.3e1 * np.exp(S) / tau ** 3 - 0.1e1) / spd + spd) - tau / kappa * ((-spd * (-0.2e1 * np.exp(S) / tau ** 2 + tau) + v_x * mu * v / tau ** 2 + T_x * kappa / tau ** 2 + v * (-0.3e1 * np.exp(S) / tau ** 3 - 0.1e1)) / spd + spd * v + v_x * mu / tau - np.exp(S) / tau ** 2 + tau), -v / kappa - tau / kappa * (spd - v / tau)] ]) return out
def A(x, lamda, s, p): v = soln(x, s) b = 1 / v[0] h = 1 - p['a'] * p['gamma'] * v[0]**(-p['gamma'] - 1) + v[1] / (v[0]**2) - lamda / v[0] out = np.array( [[0, lamda, 1, 0], [0, 0, 1, 0], [0, 0, 0, 1], [lamda / p['d'], lamda / p['d'], h / p['d'], (-b / p['d'])]]) return out
def A(x, lamda, s, p): gamma = p['gamma'] a = p['a'] v = stablab.soln(x, s) v_prime = profile_ode(x, v, s, p) v_prime_prime = (1 - a * gamma * v**(-gamma - 1)) * v_prime A31 = (lamda * a * gamma * v**(-gamma) + a * gamma * (gamma + 1) * v**(-gamma - 1) * v_prime + v_prime_prime / v - lamda * v_prime / v - 2 * (v_prime**2) / (v**2)) out = v * np.array([ [-lamda, 0, 1], [0, 0, 1], [A31, lamda * v, v - a * gamma * v**(-gamma) + 2 * v_prime / v] ]) #,dtype=np.complex) return out
def error_check_local_model(p,s): """ This function error checks our model, looking for values which do not make physical sense. """ x = np.linspace(s.L,s.R,200) y = np.zeros((len(x),2)) for j in range(len(x)): temp = soln(x[j],s) y[j,0] = temp[0] y[j,1] = temp[1] # wave speed spd = p.spd # values at - infinity v_neg = p.v_neg tau_neg = p.tau_neg S_neg = p.S_neg # parameters m1 = p.m1 none = p.none mu = p.mu kappa = p.kappa r = np.zeros((len(x),1)) for j in range(len(x)): tau = y[j,0] S = y[j,1] v = v_neg - spd * (tau - tau_neg) r[j,0] = v energy = np.exp(S) / tau + tau ** 2 / 0.2e1 if energy < 0: raise ValueError('unphysical, energy should be non-negative') pressure = np.exp(S) / tau ** 2 - tau if pressure < 0: raise ValueError('unphysical, pressure should be non-negative') temperature = np.exp(S) / tau if temperature < 0: raise ValueError('unphysical, temperature should be non-negative')
def plot_profile_stable_model(p,s): """ Plots the profile equations for the stable model. """ x = np.linspace(s.L,s.R,200) y = np.zeros((len(x),2)) for j in range(len(x)): temp = stablab.soln(x[j],s) y[j,0] = temp[0] y[j,1] = temp[1] # wave speed spd = p.spd # values at - infinity v_neg = p.v_neg tau_neg = p.tau_neg S_neg = p.S_neg # parameters m1 = p.m1 none = p.none mu = p.mu kappa = p.kappa r = np.zeros((len(x),1)) w = np.zeros((len(x),1)) for j in range(len(x)): tau = y[j,0] S = y[j,1] v = v_neg - spd * (tau - tau_neg) r[j,0] = v T = np.exp(S) / tau w[j,0] = T fig = plt.figure("Profile Equations") plt.plot(x,r) plt.plot(x,y) plt.plot(x,w) plt.xlabel('x') plt.ylabel('profiles') plt.legend(['v','tau','S','T']) plt.show()
def error_check_local_model(p, s): """ This function error checks our model, looking for values which do not make physical sense. """ x = np.linspace(s.L, s.R, 200) y = np.zeros((len(x), 2)) for j in range(len(x)): temp = soln(x[j], s) y[j, 0] = temp[0] y[j, 1] = temp[1] # wave speed spd = p.spd # values at - infinity v_neg = p.v_neg tau_neg = p.tau_neg S_neg = p.S_neg # parameters m1 = p.m1 none = p.none mu = p.mu kappa = p.kappa r = np.zeros((len(x), 1)) for j in range(len(x)): tau = y[j, 0] S = y[j, 1] v = v_neg - spd * (tau - tau_neg) r[j, 0] = v energy = np.exp(S) / tau + tau**2 / 0.2e1 if energy < 0: raise ValueError('unphysical, energy should be non-negative') pressure = np.exp(S) / tau**2 - tau if pressure < 0: raise ValueError('unphysical, pressure should be non-negative') temperature = np.exp(S) / tau if temperature < 0: raise ValueError('unphysical, temperature should be non-negative')
def A(x, lam, sol, p): y = soln([x], sol) y = y[0] Ux = profile_ode(x, y, sol, p) f = 2 * y[0] - 1 - p['Gamma'] * p['e_minus'] g = (p['Gamma'] * y[1] - (p['nu'] + 1) * Ux[0]) / p['nu'] a21 = lam * y[0] / p['nu'] a22 = y[0] / p['nu'] a23 = y[0] * Ux[0] / p['nu'] - f * Ux[0] - p['Gamma'] * Ux[1] a24 = lam * g a25 = g + Ux[1] / y[0] a53 = lam * y[0] + p['Gamma'] * Ux[0] a55 = f - lam out = np.array([[0, 1, 0, 0, 0], [a21, a22, a23, a24, a25], [0, 0, 0, lam, 1], [0, 0, 0, 0, 1], [0, p['Gamma'], a53, lam * y[0], a55]]) return out
def plot_profile_local_model(p, s): x = np.linspace(s.L, s.R, 200) y = np.zeros((len(x), 2)) for j, xVal in enumerate(x): temp = soln(xVal, s) y[j, 0] = temp[0] y[j, 1] = temp[1] # wave speed spd = p.spd # values at - infinity v_neg = p.v_neg tau_neg = p.tau_neg S_neg = p.S_neg # parameters m1 = p.m1 none = p.none mu = p.mu kappa = p.kappa r = np.zeros(len(x)) w = np.zeros(len(x)) for j in range(len(x)): tau = y[j, 0] S = y[j, 1] v = v_neg - spd * (tau - tau_neg) r[j] = v T = np.exp(S) / tau + 0.1e1 w[j] = T plt.plot(x, r) plt.plot(x, y) plt.plot(x, w) plt.xlabel('x') plt.ylabel('profiles') plt.legend(['v', 'tau', 'S', 'T', 'Location', 'Best']) plt.show()
def plot_profile_local_model(p,s): x = np.linspace(s.L,s.R,200) y = np.zeros((len(x),2)) for j,xVal in enumerate(x): temp = soln(xVal,s) y[j,0] = temp[0] y[j,1] = temp[1] # wave speed spd = p.spd # values at - infinity v_neg = p.v_neg tau_neg = p.tau_neg S_neg = p.S_neg # parameters m1 = p.m1 none = p.none mu = p.mu kappa = p.kappa r = np.zeros(len(x)) w = np.zeros(len(x)) for j in range(len(x)): tau = y[j,0] S = y[j,1] v = v_neg - spd * (tau - tau_neg) r[j] = v T = np.exp(S) / tau + 0.1e1 w[j] = T plt.plot(x,r) plt.plot(x,y) plt.plot(x,w) plt.xlabel('x') plt.ylabel('profiles') plt.legend(['v','tau','S','T','Location','Best']) plt.show()
def A(x,lam,sol,p): y = soln([x],sol) y = y[0] Ux = profile_ode(x,y,sol,p) f = 2*y[0]-1-p['Gamma']*p['e_minus'] g = (p['Gamma']*y[1]-(p['nu']+1)*Ux[0])/p['nu'] a21 = lam*y[0]/p['nu'] a22 = y[0]/p['nu'] a23 = y[0]*Ux[0]/p['nu'] - f*Ux[0] - p['Gamma']*Ux[1] a24 = lam*g a25 = g+Ux[1]/y[0]; a53 = lam*y[0]+p['Gamma']*Ux[0]; a55 = f-lam; out = np.array([[0, 1, 0, 0, 0], [a21, a22, a23, a24, a25], [0, 0, 0, lam, 1], [0, 0, 0, 0, 1], [0, p['Gamma'], a53, lam*y[0], a55]]) return out
'Flinear': profile_jacobian, # J is the profile ode Jacobian 'UL': np.array([p['v_minus'],p['e_minus']]), # These are the endstates of the profile and its derivative at x = -infty 'UR': np.array([p['v_plus'],p['e_plus']]), # These are the endstates of the profile and its derivative at x = +infty 'tol': 1e-7 }) sol.update({ 'phase': 0.5*(sol['UL']+sol['UR']), # this is the phase condition for the profile at x = 0 'order': [1], # this indicates to which component the phase conditions is applied 'stats': 'on', # this prints data and plots the profile as it is solved 'bvp_options': {'Tol': 1e-6, 'Nmax': 200} }) p,s = profile_flux(p,sol) x = np.linspace(s['L'],s['R'],200) y = soln(x,s) plt.figure("Profile") plt.plot(x,y) plt.show() # set STABLAB structures to local default values #s, e, m, c = emcset(s, 'front', [2,3], 'reg_adj_compound', A, A_k) s, e, m, c = emcset(s,'front',[2,3],'reg_reg_polar',A) circpnts, imagpnts, innerpnts = 20, 30, 5 r = 10 spread = 4 zerodist = 10**(-2) # ksteps, lambda_steps = 32, 0 preimage = semicirc2(circpnts, imagpnts, innerpnts, c['ksteps'],
def A_local_model_balflux(x, lamda, s, p): """ Balanced flux Evans matrix for the system named local_model. """ # wave speed spd = p['spd'] # parameters v_neg = p['v_neg'] tau_neg = p['tau_neg'] S_neg = p['S_neg'] m1 = p['m1'] none = p['none'] mu = p['mu'] kappa = p['kappa'] # interpolate profile solution temp = soln(x, s) #profile values tau = temp[0] S = temp[1] ynot = np.array([tau, S]) temp2 = F_local_model(x, ynot, s, p) tau_x = temp2[0] S_x = temp2[1] v = v_neg - spd * (tau - tau_neg) v_x = -spd * tau_x T_x = S_x * np.exp(S) / tau - np.exp(S) / tau**2 * tau_x # Evans matrix out = np.array( [[lamda / spd, 0, 0, -0.1e1 / spd, 0], [0, 0, 0, 1, 0], [ lamda * (-np.exp(S) / tau**2 + tau - (np.exp(S) / tau + 0.1e1) / tau) / spd, 0, 0, -(-np.exp(S) / tau**2 + tau - (np.exp(S) / tau + 0.1e1) / tau) / spd + v, (np.exp(S) / tau + 0.1e1) / np.exp(S) * tau ], [ lamda * tau / mu * (v_x * mu / tau**2 - 0.3e1 * np.exp(S) / tau**3 - 0.1e1) / spd, lamda * tau / mu, 0, -tau / mu * ((v_x * mu / tau**2 - 0.3e1 * np.exp(S) / tau**3 - 0.1e1) / spd + spd), 0.1e1 / mu ], [ lamda * (-v * tau / kappa * (v_x * mu / tau**2 - 0.3e1 * np.exp(S) / tau**3 - 0.1e1) + tau / kappa * (-spd * (-np.exp(S) / tau**2 + tau - (np.exp(S) / tau + 0.1e1) / tau) + v_x * mu * v / tau**2 + T_x * kappa / tau**2 + v * (-0.3e1 * np.exp(S) / tau**3 - 0.1e1))) / spd, -lamda * v * tau / kappa, lamda * tau / kappa, v * tau / kappa * ((v_x * mu / tau**2 - 0.3e1 * np.exp(S) / tau**3 - 0.1e1) / spd + spd) - tau / kappa * ((-spd * (-np.exp(S) / tau**2 + tau - (np.exp(S) / tau + 0.1e1) / tau) + v_x * mu * v / tau**2 + T_x * kappa / tau**2 + v * (-0.3e1 * np.exp(S) / tau**3 - 0.1e1)) / spd + spd * v + v_x * mu / tau - np.exp(S) / tau**2 + tau), -v / kappa - tau / kappa * (spd * (np.exp(S) / tau + 0.1e1) / np.exp(S) * tau - v / tau) ]]) return out
s.UL = np.array([1 ]) # These are the endstates of the profile at x = -infty s.UR = np.array([p.vp ]) # These are the endstates of the profile at x = +infty s.phase = 0.5 * (s.UL + s.UR ) # this is the phase condition for the profile at x = 0 s.order = [ 0 ] # this indicates to which componenet the phase conditions is applied s.stats = 'on' # this prints data and plots the profile as it is solved s.bvp_options = {'Tol': 1e-9} p, s = stablab.profile_flux(p, s) # solve profile for first time # plot the profile x = np.linspace(s.L, s.R, 200) y = stablab.soln(x, s) plt.plot(x, y) plt.show() # This choice solves the right hand side via exterior products s.A = A s.Ak = Ak #s,e,m,c = stablab.emcset(s, 'front', [1,2], 'reg_adj_compound', A, Ak) s, e, m, c = stablab.emcset(s, 'front', [1, 2], 'reg_reg_polar', A) #s,e,m,c = emcset(s,'front',[1,2],'reg_adj_polar') m.options = {} m.options['AbsTol'] = 1e-9 m.options['RelTol'] = 1e-9 # display a waitbar c.stats = 'print' # 'on', 'print', or 'off'
0 ] # this indicates to which componenet the phase conditions is applied s.stats = 'on' # this prints data and plots the profile as it is solved if j == 0: # there are some other options you specify. You can look in profile_flux to see them p, s = profile_flux(p, s) # solve profile for first time s_old = s else: # this time we are using continuation p, s = profile_flux(p, s, s_old) # solve profile # plot the profile x = np.linspace(s.L, s.R, 200) y = soln(x, s) plt.title("Profile") plt.plot(x, y[:, 0]) plt.plot(x, y[:, 1]) plt.show() # structure variables # Here you can choose the method you use for the Evans function, or you can set the option # to default and let it choose. [2,2] is the size of the manifold evolving from - and + infy in the # Evans solver. 'front' indicates you are solving for a traveling wave front and not a periodic solution # s,e,m,c = emcset(s,'front',LdimRdim(A,s,p),'default') # default for capillarity is reg_reg_polar # s,e,m,c = emcset(s,'front',[2,2],'reg_adj_polar') # s,e,m,c = emcset(s,'front',[2,2],'adj_reg_polar') # s,e,m,c = emcset(s,'front',[2,2],'reg_reg_polar')