示例#1
0
		inputdeck = importlib.import_module(outfile.replace('.py',''))

		# Run the simulation
		os.system("quail " + outfile)

		# Access and process the final time step
		final_file = inputdeck.Output['Prefix'] + '_final.pkl'

		# Read data file
		solver = readwritedatafiles.read_data_file(final_file)
		# Unpack
		mesh = solver.mesh
		physics = solver.physics

		# Compute L2 error
		tot_err,_ = post.get_error( mesh, physics, solver, "Density", normalize_by_volume=False)
		l2err[j, i] = tot_err
		print(f'Nelems in x: {meshx[i]}')
		if (int(np.sqrt(solver.mesh.num_elems)) != meshx[i]) or (tot_err > 1.0) or (np.isnan(tot_err)):
			inputdeck.TimeStepping['TimeStepSize'] = inputdeck.TimeStepping['TimeStepSize'] / 3.
			i-=1
		i+=1

	print(f'Output file P{(order[0] + j)}: Solution Order is {solver.order}')
	file_out = f'convergence_testing/{timestepper}/P{str(order[j])}.pkl'
	write_file(file_out, l2err[j, :])	
	if solver.order != order[0] + j:
		inputdeck.TimeStepping['TimeStepSize'] = inputdeck.TimeStepping['TimeStepSize'] / 3.
		j-=1
	# update while loop
	j+=1
示例#2
0
import processing.post as post
import processing.plot as plot
import processing.readwritedatafiles as readwritedatafiles

# Read data file
fname = "Data_final.pkl"
solver = readwritedatafiles.read_data_file(fname)

# Unpack
mesh = solver.mesh
physics = solver.physics

# Compute L2 error
solver.time = 0.  # reset time due to periodicity
post.get_error(mesh, physics, solver, "Scalar")
''' Plot '''
# Scalar contour
plot.prepare_plot(linewidth=0.5)
plot.plot_solution(mesh,
                   physics,
                   solver,
                   "Scalar",
                   plot_numerical=True,
                   create_new_figure=True,
                   include_mesh=True,
                   regular_2D=True,
                   equal_AR=False,
                   show_elem_IDs=True)
# Save figure
plot.save_figure(file_name='gaussian', file_type='pdf', crop_level=2)
示例#3
0
import numpy as np
import processing.post as post
import processing.plot as plot
import processing.readwritedatafiles as readwritedatafiles

# Read data file
fname = "Data_final.pkl"
solver = readwritedatafiles.read_data_file(fname)

# Unpack
mesh = solver.mesh
physics = solver.physics

# Compute L2 error
post.get_error(mesh, physics, solver, "Pressure", normalize_by_volume=False)

''' Plot '''
# Pressure contour
plot.prepare_plot(linewidth=0.5)
plot.plot_solution(mesh, physics, solver, "Pressure", plot_numerical=True, 
		plot_exact=False, plot_IC=False, create_new_figure=True, 
		fmt='bo', legend_label="DG", include_mesh=False,  regular_2D=True, 
		equal_AR=False)
# Save figure
plot.save_figure(file_name='Pressure', file_type='pdf', crop_level=2)

plot.show_plot()
示例#4
0
import processing.post as post
import processing.plot as plot
import processing.readwritedatafiles as readwritedatafiles

### Postprocess RestartFile First
fname = "Data_final.pkl"
solver = readwritedatafiles.read_data_file(fname)
print('Restart File Start Time:', solver.time)

# Unpack DG Solution
mesh = solver.mesh
physics = solver.physics

# Compute L2 error
TotErr, _ = post.get_error(mesh, physics, solver, "Scalar")

# Plot
plot.prepare_plot()
plot.plot_solution(mesh, physics, solver, "Scalar", plot_numerical=True,
		plot_exact=False, plot_IC=False, create_new_figure=True, fmt='go-',
		legend_label="DG RestartFile")

### Postprocess ADER Solution Second
fname = "ader_final.pkl"
solver = readwritedatafiles.read_data_file(fname)
print('Solution Final Time:', solver.time)

# Unpack ADERDG Solution
mesh = solver.mesh
physics = solver.physics
示例#5
0
import processing.post as post
import processing.plot as plot
import processing.readwritedatafiles as readwritedatafiles

# Read data file
fname = "Data_final.pkl"
solver = readwritedatafiles.read_data_file(fname)

# Unpack
mesh = solver.mesh
physics = solver.physics

# Compute L2 error
post.get_error(mesh, physics, solver, "Density")

''' Plot '''
# Density contour
plot.prepare_plot(linewidth=0.5)
plot.plot_solution(mesh, physics, solver, "Density", plot_numerical=True, 
		plot_exact=False, plot_IC=False, create_new_figure=True, fmt='bo', 
		legend_label="DG", include_mesh=True, regular_2D=True, 
		show_elem_IDs=True)

### Line probe (y = 1) ###
plot.prepare_plot(close_all=False, linewidth=1.5)
# Parameters
xy1 = [-5.,1.]; xy2 = [5.,1.]
# Initial condition
plot.plot_line_probe(mesh, physics, solver, "Density", xy1=xy1, xy2=xy2, 
		plot_numerical=False, plot_exact=False, plot_IC=True, 
		create_new_figure=True, ylabel=None, vs_x=True, fmt="k-.", 
示例#6
0
import processing.post as post
import processing.plot as plot
import processing.readwritedatafiles as readwritedatafiles

# Read data file
fname = "p2_final.pkl"
solver = readwritedatafiles.read_data_file(fname)

# Unpack
mesh = solver.mesh
physics = solver.physics

# Compute L2 error
post.get_error(mesh, physics, solver, "Entropy", normalize_by_volume=False)
''' Plot '''
### Pressure contour ###
plot.prepare_plot(linewidth=0.5)
plot.plot_solution(mesh,
                   physics,
                   solver,
                   "Pressure",
                   plot_numerical=True,
                   create_new_figure=True,
                   include_mesh=True,
                   regular_2D=False,
                   show_elem_IDs=True)
# Save figure
plot.save_figure(file_name='Pressure', file_type='pdf', crop_level=2)

### Entropy contour ###
plot.plot_solution(mesh,
示例#7
0
import processing.post as post
import processing.plot as plot
import processing.readwritedatafiles as readwritedatafiles

# Read data file
fname = "Data_final.pkl"
solver = readwritedatafiles.read_data_file(fname)

# Unpack
mesh = solver.mesh
physics = solver.physics

# Compute L2 error
post.get_error(mesh, physics, solver, "Pressure")
''' Plot '''
# Pressure contour
plot.prepare_plot(linewidth=0.5)
plot.plot_solution(mesh,
                   physics,
                   solver,
                   "Pressure",
                   plot_numerical=True,
                   plot_exact=False,
                   plot_IC=False,
                   create_new_figure=True,
                   fmt='bo',
                   legend_label="DG",
                   include_mesh=True,
                   regular_2D=True,
                   equal_AR=False,
                   show_elem_IDs=True)