예제 #1
0
def stress(current_data):    
    import numpy as np
    from psystem import setaux
    aux = setaux(current_data.x[:,0],current_data.y[0,:])
    q = current_data.q
    #return np.exp(aux[1,...]*q[0,...])-1.
    return aux[1,...]*q[0,...]
예제 #2
0
def rwave(current_data):
    from psystem import setaux
    import numpy as np
    aux = setaux(current_data.x[:,0],current_data.y[0,:])
    z = np.sqrt(aux[0,...]*aux[1,...])
    sigma = stress(current_data)
    u = xvel(current_data)
    return -(z*u-sigma)/(2.*z)
from clawpack import petclaw
from psystem import setaux
import matplotlib.pyplot as plt
import numpy as np

sol = petclaw.Solution(100,file_format='petsc')
xc = sol.state.grid.x.centers
yc = sol.state.grid.y.centers
q = sol.q
aux = setaux(xc,yc)
u = q[1,...]/aux[0,...]
v = q[2,...]/aux[0,...]

X, Y = np.meshgrid(xc,yc,indexing='ij')

plt.figure()
plt.pcolor(X,Y,q[0,...],cmap='RdBu')
plt.hold(True)
x_skip = 8
y_skip = 4
plt.quiver(X[::x_skip,::y_skip],Y[::x_skip,::y_skip],u[::x_skip,::y_skip],10*v[::x_skip,::y_skip],pivot='center',units='width',linewidth=1.5,headaxislength=5,scale=100)
plt.axis([18,32,0,1])
plt.xlabel('x'); plt.ylabel('y')
plt.hold(False)
plt.show()
예제 #4
0
from clawpack import petclaw
from psystem import setaux
import matplotlib.pyplot as plt
import numpy as np

sol = petclaw.Solution(100, file_format='petsc')
xc = sol.state.grid.x.centers
yc = sol.state.grid.y.centers
q = sol.q
aux = setaux(xc, yc)
u = q[1, ...] / aux[0, ...]
v = q[2, ...] / aux[0, ...]

X, Y = np.meshgrid(xc, yc, indexing='ij')

plt.figure()
plt.pcolor(X, Y, q[0, ...], cmap='RdBu')
plt.hold(True)
x_skip = 8
y_skip = 4
plt.quiver(X[::x_skip, ::y_skip],
           Y[::x_skip, ::y_skip],
           u[::x_skip, ::y_skip],
           10 * v[::x_skip, ::y_skip],
           pivot='center',
           units='width',
           linewidth=1.5,
           headaxislength=5,
           scale=100)
plt.axis([18, 32, 0, 1])
plt.xlabel('x')
예제 #5
0
def sound_speed(current_data):
    from psystem import setaux
    import numpy as np
    aux = setaux(current_data.x[:,0],current_data.y[0,:])
    c = np.sqrt(aux[1,...]/aux[0,...])
    return c
예제 #6
0
def yvel(current_data):    
    from psystem import setaux
    aux = setaux(current_data.x[:,0],current_data.y[0,:])
    q = current_data.q
    return q[2,...]/aux[0,...]