from IPython.core.display import HTML
css_file = './custom.css'
HTML(open(css_file, "r").read())
from clawpack import pyclaw
from clawpack import riemann
claw = pyclaw.Controller()
claw.tfinal = 0.1 # Simulation end time
claw.keep_copy = True # Keep solution data in memory for plotting
claw.output_format = None # Don't write solution data to file
claw.num_output_times = 50 # Write 50 output frames
riemann.
riemann_solver = riemann.euler_with_efix_1D
claw.solver = pyclaw.ClawSolver1D(riemann_solver)
claw.solver.all_bcs = pyclaw.BC.extrap
domain = pyclaw.Domain( (0.,), (1.,), (100,))
claw.solution = pyclaw.Solution(claw.solver.num_eqn,domain)
x=domain.grid.x.centers # grid cell centers
gam = 1.4 # ratio of specific heats
rho_left = 1.0; rho_right = 0.125
p_left = 1.0; p_right = 0.1
claw.solution.q[0,:] = (x<0.5)*rho_left + (x>=0.5)*rho_right
claw.solution.q[1,:] = 0.
claw.solution.q[2,:] = ((x<0.5)*p_left + (x>=0.5)*p_right)/(gam-1.0)
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot(x, claw.solution.q[0,:],'-o')
problem_data = claw.solution.problem_data
problem_data['gamma'] = 1.4
problem_data['gamma1'] = 0.4
claw.run()
from matplotlib import animation
import matplotlib.pyplot as plt
from clawpack.visclaw.JSAnimation import IPython_display
import numpy as np
fig = plt.figure()
ax = plt.axes(xlim=(0, 1), ylim=(-0.2, 1.2))
frame = claw.frames[0]
pressure = frame.q[0,:]
line, = ax.plot([], [], 'o-', lw=2)
def fplot(frame_number):
frame = claw.frames[frame_number]
pressure = frame.q[0,:]
line.set_data(x,pressure)
return line,
animation.FuncAnimation(fig, fplot, frames=len(claw.frames), interval=30)
%matplotlib inline
import matplotlib.pyplot as plt
from clawpack import pyclaw
from clawpack import riemann
claw = pyclaw.Controller()
claw.tfinal = 0.1
claw.keep_copy = True # Keep solution data in memory for plotting
claw.output_format = None # Don't write solution data to file
claw.num_output_times = 50 # Write 50 output frames
riemann_solver = riemann.euler_with_efix_1D
claw.solver = pyclaw.ClawSolver1D(riemann_solver)
claw.solver.all_bcs = pyclaw.BC.extrap
domain = pyclaw.Domain( (0.,), (1.,), (100,))
x=domain.grid.x.centers # grid cell centers
claw.solution = pyclaw.Solution(claw.solver.num_eqn,domain)
gam = 1.4 # ratio of specific heats
claw.solution.problem_data['gamma'] = gam
claw.solution.problem_data['gamma1'] = gam-1.0
rho_left = 1.0; rho_right = 0.125
p_left = 1.0; p_right = 0.1
claw.solution.q[0,:] = (x<0.5)*rho_left + (x>=0.5)*rho_right
claw.solution.q[1,:] = 0.
claw.solution.q[2,:] = ((x<0.5)*p_left + (x>=0.5)*p_right)/(gam-1.0)
status = claw.run()