From c68db1cafb8e82dafb0834a76655f89b8285819f Mon Sep 17 00:00:00 2001 From: Kyle Mandli Date: Thu, 6 Feb 2025 11:48:41 -0500 Subject: [PATCH] Move and rename acoustics 1d test into examples directory --- .../regression_data/claw_git_diffs.txt | 0 .../regression_data/claw_git_status.txt | 0 .../regression_data/regression_data_test2.txt | 0 .../regression_data/regression_data_test3.txt | 0 tests/acoustics_1d_heterogeneous/Makefile | 60 ----- tests/acoustics_1d_heterogeneous/README.rst | 12 - tests/acoustics_1d_heterogeneous/__init__.py | 0 tests/acoustics_1d_heterogeneous/qinit.f | 65 ----- .../regression_test.py | 45 ---- tests/acoustics_1d_heterogeneous/setaux.f | 38 --- tests/acoustics_1d_heterogeneous/setplot.py | 39 --- tests/acoustics_1d_heterogeneous/setprob.f | 35 --- tests/acoustics_1d_heterogeneous/setrun.py | 229 ------------------ 13 files changed, 523 deletions(-) rename {tests => examples}/acoustics_1d_heterogeneous/regression_data/claw_git_diffs.txt (100%) rename {tests => examples}/acoustics_1d_heterogeneous/regression_data/claw_git_status.txt (100%) rename {tests => examples}/acoustics_1d_heterogeneous/regression_data/regression_data_test2.txt (100%) rename {tests => examples}/acoustics_1d_heterogeneous/regression_data/regression_data_test3.txt (100%) delete mode 100644 tests/acoustics_1d_heterogeneous/Makefile delete mode 100644 tests/acoustics_1d_heterogeneous/README.rst delete mode 100644 tests/acoustics_1d_heterogeneous/__init__.py delete mode 100644 tests/acoustics_1d_heterogeneous/qinit.f delete mode 100644 tests/acoustics_1d_heterogeneous/regression_test.py delete mode 100644 tests/acoustics_1d_heterogeneous/setaux.f delete mode 100644 tests/acoustics_1d_heterogeneous/setplot.py delete mode 100644 tests/acoustics_1d_heterogeneous/setprob.f delete mode 100644 tests/acoustics_1d_heterogeneous/setrun.py diff --git a/tests/acoustics_1d_heterogeneous/regression_data/claw_git_diffs.txt b/examples/acoustics_1d_heterogeneous/regression_data/claw_git_diffs.txt similarity index 100% rename from tests/acoustics_1d_heterogeneous/regression_data/claw_git_diffs.txt rename to examples/acoustics_1d_heterogeneous/regression_data/claw_git_diffs.txt diff --git a/tests/acoustics_1d_heterogeneous/regression_data/claw_git_status.txt b/examples/acoustics_1d_heterogeneous/regression_data/claw_git_status.txt similarity index 100% rename from tests/acoustics_1d_heterogeneous/regression_data/claw_git_status.txt rename to examples/acoustics_1d_heterogeneous/regression_data/claw_git_status.txt diff --git a/tests/acoustics_1d_heterogeneous/regression_data/regression_data_test2.txt b/examples/acoustics_1d_heterogeneous/regression_data/regression_data_test2.txt similarity index 100% rename from tests/acoustics_1d_heterogeneous/regression_data/regression_data_test2.txt rename to examples/acoustics_1d_heterogeneous/regression_data/regression_data_test2.txt diff --git a/tests/acoustics_1d_heterogeneous/regression_data/regression_data_test3.txt b/examples/acoustics_1d_heterogeneous/regression_data/regression_data_test3.txt similarity index 100% rename from tests/acoustics_1d_heterogeneous/regression_data/regression_data_test3.txt rename to examples/acoustics_1d_heterogeneous/regression_data/regression_data_test3.txt diff --git a/tests/acoustics_1d_heterogeneous/Makefile b/tests/acoustics_1d_heterogeneous/Makefile deleted file mode 100644 index f3f2989..0000000 --- a/tests/acoustics_1d_heterogeneous/Makefile +++ /dev/null @@ -1,60 +0,0 @@ - -# Makefile for Clawpack code in this directory. -# This version only sets the local files and frequently changed -# options, and then includes the standard makefile pointed to by CLAWMAKE. -CLAWMAKE = $(CLAW)/clawutil/src/Makefile.common - -# See the above file for details and a list of make options, or type -# make .help -# at the unix prompt. - - -# Adjust these variables if desired: -# ---------------------------------- - -CLAW_PKG = classic # Clawpack package to use -EXE = xclaw # Executable to create -SETRUN_FILE = setrun.py # File containing function to make data -OUTDIR = _output # Directory for output -SETPLOT_FILE = setplot.py # File containing function to set plots -PLOTDIR = _plots # Directory for plots - -OVERWRITE ?= True # False ==> make a copy of OUTDIR first -RESTART ?= False # Should = clawdata.restart in setrun - -# Environment variable FC should be set to fortran compiler, e.g. gfortran - -# Compiler flags can be specified here or set as an environment variable -FFLAGS ?= - -# --------------------------------- -# package sources for this program: -# --------------------------------- - -include $(CLAW)/classic/src/1d/Makefile.classic_1d - -# --------------------------------------- -# package sources specifically to exclude -# (i.e. if a custom replacement source -# under a different name is provided) -# --------------------------------------- - -EXCLUDE_MODULES = \ - -EXCLUDE_SOURCES = \ - -# ---------------------------------------- -# List of custom sources for this program: -# ---------------------------------------- -MODULES = \ - -SOURCES = \ - qinit.f \ - setprob.f \ - setaux.f \ - $(CLAW)/riemann/src/rp1_acoustics_variable.f90 \ - -#------------------------------------------------------------------- -# Include Makefile containing standard definitions and make options: -include $(CLAWMAKE) - diff --git a/tests/acoustics_1d_heterogeneous/README.rst b/tests/acoustics_1d_heterogeneous/README.rst deleted file mode 100644 index 2fee8ff..0000000 --- a/tests/acoustics_1d_heterogeneous/README.rst +++ /dev/null @@ -1,12 +0,0 @@ - -.. _classic_tests_acoustics_1d_heterogeneous: - -Acoustics 1D Example 1 ------------------------------------------- - -1D acoustics in a piecewise constant medium to illustrate reflection and -transmission at an interface. - -Quick regression test version: regression_tests.py - -* Checks sum of p values and of u values for two frames. diff --git a/tests/acoustics_1d_heterogeneous/__init__.py b/tests/acoustics_1d_heterogeneous/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/acoustics_1d_heterogeneous/qinit.f b/tests/acoustics_1d_heterogeneous/qinit.f deleted file mode 100644 index 6e57528..0000000 --- a/tests/acoustics_1d_heterogeneous/qinit.f +++ /dev/null @@ -1,65 +0,0 @@ -c -c -c========================================================= - subroutine qinit(meqn,mbc,mx,xlower,dx,q,maux,aux) -c========================================================= -c -c # Set initial conditions for q. -c # Pulse in pressure, zero velocity -c -c - implicit none - - integer, intent(in) :: meqn, mbc, mx, maux - double precision, intent(in) :: xlower, dx, aux - double precision, intent(out) :: q - dimension q(meqn, 1-mbc:mx+mbc) - dimension aux(maux, 1-mbc:mx+mbc) - - common /cqinit/ beta,ic - double precision beta - integer ic - - integer i - double precision xcell -c -c - do 150 i=1,mx - xcell = xlower + (i-0.5d0)*dx - - go to (10,20,30) ic - - 10 continue -c # half ellipse: - if (xcell.gt.-4d0 .and. xcell.lt.-2d0) then - q(1,i) = dsqrt(1.d0 - (xcell+3.d0)**2) - else - q(1,i) = 0.d0 - endif - q(2,i) = q(1,i) - go to 150 - - 20 continue -c # single discontinuity: - if (xcell .lt. -2.d0) then - q(1,i) = 1.d0 - else - q(1,i) = 0.d0 - endif - q(2,i) = q(1,i) - go to 150 - - 30 continue -c # Gaussian and square pulse: - q(1,i) = dexp(-beta*(xcell+2.0d0)**2) - if (dabs(q(1,i)) .lt. 1d-30) q(1,i) = 0.d0 - if (xcell.gt.-4.d0 .and. xcell.lt.-3.d0) then - q(1,i) = q(1,i) + 0.5d0 - endif - q(2,i) = q(1,i) - go to 150 - - 150 continue -c - return - end diff --git a/tests/acoustics_1d_heterogeneous/regression_test.py b/tests/acoustics_1d_heterogeneous/regression_test.py deleted file mode 100644 index 1cc2380..0000000 --- a/tests/acoustics_1d_heterogeneous/regression_test.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -Regression tests for a 1D heterogeneous acoustics test -""" - -from __future__ import absolute_import -import sys -import unittest - -import clawpack.classic.test as test - - -class Acoustics1DHeterogeneousTest(test.ClassicRegressionTest): - r"""Basic test for an 1D heterogeneous acoustics test case""" - - def runTest(self, save=False): - - # Write out data files - self.load_rundata() - self.write_rundata_objects() - - # Run code - self.run_code() - - # Perform tests - self.check_frame(indices=[0, 1], save=save, frame_num=1, - file_name='regression_data_test2.txt') - self.check_frame(indices=[0, 1], save=save, frame_num=2, - file_name='regression_data_test3.txt') - - self.success = True - - - -if __name__=="__main__": - if len(sys.argv) > 1: - if bool(sys.argv[1]): - # Fake the setup and save out output - test = Acoustics1DHeterogeneousTest() - try: - test.setUp() - test.runTest(save=True) - finally: - test.tearDown() - sys.exit(0) - unittest.main() \ No newline at end of file diff --git a/tests/acoustics_1d_heterogeneous/setaux.f b/tests/acoustics_1d_heterogeneous/setaux.f deleted file mode 100644 index dde66d6..0000000 --- a/tests/acoustics_1d_heterogeneous/setaux.f +++ /dev/null @@ -1,38 +0,0 @@ -c ============================================ - subroutine setaux(mbc,mx,xlower,dx,maux,aux) -c ============================================ -c -c # set auxiliary arrays -c # variable coefficient acoustics -c # aux(i,1) = impedance Z in i'th cell -c # aux(i,2) = sound speed c in i'th cell -c -c # Piecewise constant medium with single interface at x=0 -c # Density and sound speed to left and right are set in setprob.f -c - implicit none - - integer, intent(in) :: mbc, mx, maux - double precision, intent(in) :: xlower, dx - double precision, intent(out) :: aux - dimension aux(maux, 1-mbc:mx+mbc) - - common /comaux/ Zl, cl, Zr, cr - double precision Zl, cl, Zr, cr - - integer i - double precision xcell - - do i=1-mbc,mx+mbc - xcell = xlower + (i-0.5d0)*dx - if (xcell .lt. 0.0d0) then - aux(1,i) = Zl - aux(2,i) = cl - else - aux(1,i) = Zr - aux(2,i) = cr - endif - enddo - - return - end diff --git a/tests/acoustics_1d_heterogeneous/setplot.py b/tests/acoustics_1d_heterogeneous/setplot.py deleted file mode 100644 index bc630f7..0000000 --- a/tests/acoustics_1d_heterogeneous/setplot.py +++ /dev/null @@ -1,39 +0,0 @@ -from __future__ import absolute_import -def setplot(plotdata): - plotdata.clearfigures() - - # Figures corresponding to Figure 9.5 of LeVeque, "Finite Volume - # Methods for Hyperbolic Problems," 2002 (though more of them) - - # Tuples of (variable name, variable number) - figdata = [('Pressure', 0), - ('Velocity', 1)] - - # Afteraxes function: draw a vertical dashed line at the interface - # between different media - def draw_interface(current_data): - import pylab - pylab.plot([0., 0.], [-1000., 1000.], 'k--') - - for varname, varid in figdata: - plotfigure = plotdata.new_plotfigure(name=varname, figno=varid) - - plotaxes = plotfigure.new_plotaxes() - plotaxes.xlimits = [-5., 5.] - plotaxes.ylimits = [-0.5, 1.5] # Good for both vars because of near-unit impedance - plotaxes.title = varname - plotaxes.afteraxes = draw_interface - - plotitem = plotaxes.new_plotitem(plot_type='1d_plot') - plotitem.plot_var = varid - plotitem.color = 'b' - - plotdata.printfigs = True # Whether to output figures - plotdata.print_format = 'png' # What type of output format - plotdata.print_framenos = 'all' # Which frames to output - plotdata.print_fignos = 'all' # Which figures to print - plotdata.html = True # Whether to create HTML files - plotdata.latex = False # Whether to make LaTeX output - - return plotdata - diff --git a/tests/acoustics_1d_heterogeneous/setprob.f b/tests/acoustics_1d_heterogeneous/setprob.f deleted file mode 100644 index 31e9fc0..0000000 --- a/tests/acoustics_1d_heterogeneous/setprob.f +++ /dev/null @@ -1,35 +0,0 @@ - subroutine setprob - - implicit none - - common /cqinit/ beta,ic - integer ic - double precision beta - - common /comaux/ Zl, cl, Zr, cr - double precision rhol, Zl, cl, rhor, Zr, cr -c -c # Set the material parameters for the acoustic equations -c - character*25 fname - - fname = 'setprob.data' - call opendatafile(7, fname) - -c # choice of initial data: - read(7,*) ic -c # beta for initial conditions: - read(7,*) beta -c -c # Piecewise constant medium with single interface at x=0 -c # Density and sound speed to left and right: - read(7,*) rhol - read(7,*) cl - Zl = rhol*cl - - read(7,*) rhor - read(7,*) cr - Zr = rhor*cr - - return - end diff --git a/tests/acoustics_1d_heterogeneous/setrun.py b/tests/acoustics_1d_heterogeneous/setrun.py deleted file mode 100644 index 59c5ceb..0000000 --- a/tests/acoustics_1d_heterogeneous/setrun.py +++ /dev/null @@ -1,229 +0,0 @@ -""" -Module to set up run time parameters for Clawpack -- classic code. - -The values set in the function setrun are then written out to data files -that will be read in by the Fortran code. - -""" - -from __future__ import absolute_import -import os -import numpy as np - -#------------------------------ -def setrun(claw_pkg='classic'): -#------------------------------ - - """ - Define the parameters used for running Clawpack. - - INPUT: - claw_pkg expected to be "classic" for this setrun. - - OUTPUT: - rundata - object of class ClawRunData - - """ - - from clawpack.clawutil import data - - - assert claw_pkg.lower() == 'classic', "Expected claw_pkg = 'classic'" - - num_dim = 1 - rundata = data.ClawRunData(claw_pkg, num_dim) - - #------------------------------------------------------------------ - # Problem-specific parameters to be written to setprob.data: - #------------------------------------------------------------------ - # Sample setup to write one line to setprob.data ... - probdata = rundata.new_UserData(name='probdata',fname='setprob.data') - probdata.add_param('ic', 1, 'Initial condition type') - probdata.add_param('beta', 5., 'Gaussian hump width parameter') - probdata.add_param('rhol', 1., 'Density left of interface') - probdata.add_param('cl', 1., 'Sound speed left of interface') - probdata.add_param('rhor', 4., 'Density right of interface') - probdata.add_param('cr', 0.5, 'Sound speed right of interface') - - #------------------------------------------------------------------ - # Standard Clawpack parameters to be written to claw.data: - #------------------------------------------------------------------ - - clawdata = rundata.clawdata # initialized when rundata instantiated - - - # --------------- - # Spatial domain: - # --------------- - - # Number of space dimensions: - clawdata.num_dim = num_dim - - # Lower and upper edge of computational domain: - clawdata.lower[0] = -5. # xlower - clawdata.upper[0] = 5. # xupper - - # Number of grid cells: - clawdata.num_cells[0] = 500 # mx - - - # --------------- - # Size of system: - # --------------- - - # Number of equations in the system: - clawdata.num_eqn = 2 - - # Number of auxiliary variables in the aux array (initialized in setaux) - clawdata.num_aux = 2 - - # Index of aux array corresponding to capacity function, if there is one: - clawdata.capa_index = 0 - - - # ------------- - # Initial time: - # ------------- - - clawdata.t0 = 0. - - - # Restart from checkpoint file of a previous run? - # Note: If restarting, you must also change the Makefile to set: - # RESTART = True - # If restarting, t0 above should be from original run, and the - # restart_file 'fort.qNNNN' specified below should be in - # the OUTDIR indicated in Makefile. - - clawdata.restart = False # True to restart from prior results - clawdata.restart_file = 'fort.q0006' # File to use for restart data - - - # ------------- - # Output times: - #-------------- - - # Specify at what times the results should be written to fort.q files. - # Note that the time integration stops after the final output time. - - clawdata.output_style = 1 - - if clawdata.output_style==1: - # Output ntimes frames at equally spaced times up to tfinal: - # Can specify num_output_times = 0 for no output - clawdata.num_output_times = 2 - clawdata.tfinal = 5. - clawdata.output_t0 = False # output at initial (or restart) time? - - elif clawdata.output_style == 2: - # Specify a list or numpy array of output times: - # Include t0 if you want output at the initial time. - clawdata.output_times = [0., 0.1] - - elif clawdata.output_style == 3: - # Output every step_interval timesteps over total_steps timesteps: - clawdata.output_step_interval = 2 - clawdata.total_steps = 4 - clawdata.output_t0 = True # output at initial (or restart) time? - - - clawdata.output_format = 'ascii' # 'ascii', 'binary', 'netcdf' - - clawdata.output_q_components = 'all' # could be list such as [True,True] - clawdata.output_aux_components = 'none' # could be list - clawdata.output_aux_onlyonce = True # output aux arrays only at t0 - - - # --------------------------------------------------- - # Verbosity of messages to screen during integration: - # --------------------------------------------------- - - # The current t, dt, and cfl will be printed every time step - # at AMR levels <= verbosity. Set verbosity = 0 for no printing. - # (E.g. verbosity == 2 means print only on levels 1 and 2.) - clawdata.verbosity = 0 - - - - # -------------- - # Time stepping: - # -------------- - - # if dt_variable==True: variable time steps used based on cfl_desired, - # if dt_variable==False: fixed time steps dt = dt_initial always used. - clawdata.dt_variable = True - - # Initial time step for variable dt. - # (If dt_variable==0 then dt=dt_initial for all steps) - clawdata.dt_initial = 1. - - # Max time step to be allowed if variable dt used: - clawdata.dt_max = 1.e9 - - # Desired Courant number if variable dt used - clawdata.cfl_desired = 0.9 - # max Courant number to allow without retaking step with a smaller dt: - clawdata.cfl_max = 1.0 - - # Maximum number of time steps to allow between output times: - clawdata.steps_max = 50000 - - - # ------------------ - # Method to be used: - # ------------------ - - # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters - clawdata.order = 2 - - - # Number of waves in the Riemann solution: - clawdata.num_waves = 2 - - # List of limiters to use for each wave family: - # Required: len(limiter) == num_waves - # Some options: - # 0 or 'none' ==> no limiter (Lax-Wendroff) - # 1 or 'minmod' ==> minmod - # 2 or 'superbee' ==> superbee - # 3 or 'vanleer' ==> van Leer - # 4 or 'mc' ==> MC limiter - clawdata.limiter = [4,4] - - clawdata.use_fwaves = False # True ==> use f-wave version of algorithms - - # Source terms splitting: - # src_split == 0 or 'none' ==> no source term (src routine never called) - # src_split == 1 or 'godunov' ==> Godunov (1st order) splitting used, - # src_split == 2 or 'strang' ==> Strang (2nd order) splitting used, not recommended. - clawdata.source_split = 'none' - - - # -------------------- - # Boundary conditions: - # -------------------- - - # Number of ghost cells (usually 2) - clawdata.num_ghost = 2 - - # Choice of BCs at xlower and xupper: - # 0 or 'user' => user specified (must modify bcNamr.f to use this option) - # 1 or 'extrap' => extrapolation (non-reflecting outflow) - # 2 or 'periodic' => periodic (must specify this at both boundaries) - # 3 or 'wall' => solid wall for systems where q(2) is normal velocity - - clawdata.bc_lower[0] = 'extrap' # at xlower - clawdata.bc_upper[0] = 'extrap' # at xupper - - return rundata - - # end of function setrun - # ---------------------- - - -if __name__ == '__main__': - # Set up run-time parameters and write all data files. - import sys - rundata = setrun(*sys.argv[1:]) - rundata.write() -