Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New version of paper2_examples #3

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b1cb61a
update paper2_examples/acoustics_1d_ex1 for v5.6.1, with better plots…
rjleveque Nov 24, 2019
8483726
update acoustics_1d_ex2 to v5.6.1
rjleveque Dec 21, 2019
f132860
update paper2_examples/acoustics_2d_ex3 for v5.6.1
rjleveque Dec 22, 2019
9123266
update paper2_examples/acoustics_2d_ex4 to v5.6.1
rjleveque Dec 22, 2019
a4fb398
make it easier to change flagging method in 2d examples
rjleveque Dec 22, 2019
9fe5d76
update paper2_examples/README
rjleveque Dec 22, 2019
8b3c17f
move acoustics_1d_ex1 to acoustics_1d_ex1_old
rjleveque Dec 22, 2019
8781667
move acoustics_1d_ex2 acoustics_1d_example1
rjleveque Dec 22, 2019
9a7d2ad
rename acoustics_2d_ex* directories
rjleveque Dec 22, 2019
849ef67
fixed incorrect renaming of directories in acoustics_2d_example3
rjleveque Dec 23, 2019
f4a286d
600 x 800
rjleveque Dec 26, 2019
c4c6164
updates to example3
rjleveque Dec 27, 2019
c0f1dd6
update example2 with errf1 based on LTE
rjleveque Dec 27, 2019
fef44bc
scripts for plots
rjleveque Dec 27, 2019
06eaa83
change rectangle plotted and color scale for adjoint
rjleveque Dec 27, 2019
c7681f5
increase fontsize
rjleveque Dec 27, 2019
64d1bfb
improve some plots
rjleveque Dec 28, 2019
e918ba1
revert back to original errf1 for forward-error flagging
rjleveque Dec 30, 2019
ebf0add
updates to acoustics_2d_example2 for resubmission
rjleveque Dec 31, 2019
650cf00
update some README files
rjleveque Dec 31, 2019
b3a8db4
rename since no longer using acoustics_2d_ex4_old
rjleveque Dec 31, 2019
c443c73
clean up
rjleveque Dec 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make it easier to change flagging method in 2d examples
rjleveque committed Dec 22, 2019
commit a4fb398d743a518657c46b46efa15941ecf0c348
13 changes: 10 additions & 3 deletions paper2_examples/acoustics_2d_ex3/setplot.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
"""



#--------------------------
def setplot(plotdata):
#--------------------------
@@ -20,6 +22,11 @@ def setplot(plotdata):

from clawpack.visclaw import colormaps

from clawpack.clawutil.data import ClawData
adjoint_data = ClawData()
adjoint_data.read('adjoint.data', force=True)
print('use_adjoint = ', adjoint_data.use_adjoint)

plotdata.clearfigures() # clear any old figures,axes,items data
plotdata.format = 'ascii' # 'ascii', 'binary', 'netcdf'

@@ -54,7 +61,7 @@ def setplot(plotdata):
#-----------------------------------------
plotfigure = plotdata.new_plotfigure(name='Inner Product', figno=1)
plotfigure.kwargs = {'figsize': (5.5,4)}
#plotfigure.show = False
plotfigure.show = adjoint_data.use_adjoint

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
@@ -110,8 +117,8 @@ def setplot(plotdata):
plotaxes = plotfigure.new_plotaxes()
plotaxes.xlimits = 'auto'
plotaxes.ylimits = 'auto'
plotaxes.xlimits = [1,3]
plotaxes.ylimits = [-0.4,0.5]
plotaxes.xlimits = [0,21]
plotaxes.ylimits = [-0.4,0.6]
plotaxes.title = 'Pressure'
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 0
31 changes: 17 additions & 14 deletions paper2_examples/acoustics_2d_ex3/setrun.py
Original file line number Diff line number Diff line change
@@ -243,8 +243,7 @@ def setrun(claw_pkg='amrclaw'):
# ---------------
rundata.gaugedata.gauges = []
# for gauges append lines of the form [gaugeno, x, y, t1, t2]
rundata.gaugedata.gauges.append([0, 1.0, 5.5, 18., 21.])
#rundata.gaugedata.gauges.append([1, 3.6, 0.5, 2.7, 2.85])
rundata.gaugedata.gauges.append([0, 1.0, 5.5, 0., 21.])

# --------------
# Checkpointing:
@@ -296,18 +295,8 @@ def setrun(claw_pkg='amrclaw'):
rundata.amrdata.aux_type = ['center','center']
# Note: as required for original problem - modified below for adjoint

# set tolerances appropriate for adjoint flagging:
# set tolerances for flagging in adjoint section below

# need 1 value, set in setadjoint


# Flag for refinement based on Richardson error estimater:
amrdata.flag_richardson = True
amrdata.flag_richardson_tol = 3e-3 # suggested if using adjoint error flag

# Flag for refinement using routine flag2refine:
amrdata.flag2refine = False
rundata.amrdata.flag2refine_tol = 3e-4 # suggested if using adj mag flag

# steps to take on each level L between regriddings of level L+1:
amrdata.regrid_interval = 2
@@ -336,8 +325,22 @@ def setrun(claw_pkg='amrclaw'):
#------------------------------------------------------------------
# Also need to set flagging method and appropriate tolerances above

flag_method = 'forward-diff'

assert flag_method in ['forward-diff','forward-error',\
'adjoint-mag','adjoint-error'], '*** Unsupported flag_method'

adjointdata = rundata.adjointdata
adjointdata.use_adjoint = True
adjointdata.use_adjoint = (flag_method in ['adjoint-mag','adjoint-error'])

# Flag for refinement based on Richardson error estimater:
amrdata.flag_richardson = (flag_method in ['adjoint-error','forward-error'])
amrdata.flag_richardson_tol = 3e-3 # suggested if using adjoint-error flag

# Flag for refinement using routine flag2refine:
amrdata.flag2refine = (flag_method in ['adjoint-mag','forward-diff'])
#amrdata.flag2refine_tol = 3e-4 # suggested if using adjoint-mag flag
amrdata.flag2refine_tol = 0.05 # suggested if using forward-diff

# location of adjoint solution, must first be created:
adjointdata.adjoint_outdir = os.path.abspath('adjoint/_output')
23 changes: 16 additions & 7 deletions paper2_examples/acoustics_2d_ex4/setplot.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
"""



#--------------------------
def setplot(plotdata):
#--------------------------
@@ -20,6 +22,11 @@ def setplot(plotdata):

from clawpack.visclaw import colormaps

from clawpack.clawutil.data import ClawData
adjoint_data = ClawData()
adjoint_data.read('adjoint.data', force=True)
print('use_adjoint = ', adjoint_data.use_adjoint)

plotdata.clearfigures() # clear any old figures,axes,items data
plotdata.format = 'ascii' # 'ascii', 'binary', 'netcdf'

@@ -54,7 +61,7 @@ def setplot(plotdata):
#-----------------------------------------
plotfigure = plotdata.new_plotfigure(name='Inner Product', figno=1)
plotfigure.kwargs = {'figsize': (5.5,4)}
#plotfigure.show = False
plotfigure.show = adjoint_data.use_adjoint

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
@@ -74,7 +81,8 @@ def setplot(plotdata):
plotitem.pcolor_cmin = 0.0 # use when plotting inner product with q
#plotitem.pcolor_cmin = 0.0 # use when plotting inner product with error
#plotitem.pcolor_cmax = 0.12 # use when plotting inner product with q
plotitem.pcolor_cmax = 0.000001 # use when plotting inner product with error
#plotitem.pcolor_cmax = 0.000001 # for adjoint-error
plotitem.pcolor_cmax = 0.0001 # for adjoint-mag
plotitem.amr_patchedges_show = [0,0,0]
plotitem.amr_celledges_show = [0,0,0]
plotitem.amr_data_show = [1,1,1,1,0]
@@ -110,8 +118,8 @@ def setplot(plotdata):
plotaxes = plotfigure.new_plotaxes()
plotaxes.xlimits = 'auto'
plotaxes.ylimits = 'auto'
plotaxes.xlimits = [1,3]
plotaxes.ylimits = [-0.4,0.5]
plotaxes.xlimits = [0,21]
plotaxes.ylimits = [-0.4,0.6]
plotaxes.title = 'Pressure'
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 0
@@ -176,7 +184,8 @@ def plot_rectangle(current_data):

def fixup_gauge(current_data):
import pylab
size = 34
size = 15
pylab.grid(True)
pylab.title('Pressure at Gauge 0', fontsize=size)
pylab.xticks([1.0, 1.5, 2.0, 2.5, 3.0], fontsize=size)
pylab.yticks([-0.3, -0.1, 0.1, 0.3, 0.5], fontsize=size)
#pylab.xticks([1.0, 1.5, 2.0, 2.5, 3.0], fontsize=size)
#pylab.yticks([-0.3, -0.1, 0.1, 0.3, 0.5], fontsize=size)
30 changes: 17 additions & 13 deletions paper2_examples/acoustics_2d_ex4/setrun.py
Original file line number Diff line number Diff line change
@@ -243,7 +243,7 @@ def setrun(claw_pkg='amrclaw'):
# ---------------
rundata.gaugedata.gauges = []
# for gauges append lines of the form [gaugeno, x, y, t1, t2]
rundata.gaugedata.gauges.append([0, 3.5, 0.5, 18., 21.])
rundata.gaugedata.gauges.append([0, 3.5, 0.5, 0., 21.])

# --------------
# Checkpointing:
@@ -295,18 +295,8 @@ def setrun(claw_pkg='amrclaw'):
rundata.amrdata.aux_type = ['center','center']
# Note: as required for original problem - modified below for adjoint

# set tolerances appropriate for adjoint flagging:
# set tolerances for flagging in adjoint section below

# need 1 value, set in setadjoint


# Flag for refinement based on Richardson error estimater:
amrdata.flag_richardson = True
amrdata.flag_richardson_tol = 3e-3 # suggested if using adjoint error flag

# Flag for refinement using routine flag2refine:
amrdata.flag2refine = False
rundata.amrdata.flag2refine_tol = 3e-4 # suggested if using adj mag flag

# steps to take on each level L between regriddings of level L+1:
amrdata.regrid_interval = 2
@@ -335,8 +325,22 @@ def setrun(claw_pkg='amrclaw'):
#------------------------------------------------------------------
# Also need to set flagging method and appropriate tolerances above

flag_method = 'forward-diff'

assert flag_method in ['forward-diff','forward-error',\
'adjoint-mag','adjoint-error'], '*** Unsupported flag_method'

adjointdata = rundata.adjointdata
adjointdata.use_adjoint = True
adjointdata.use_adjoint = (flag_method in ['adjoint-mag','adjoint-error'])

# Flag for refinement based on Richardson error estimater:
amrdata.flag_richardson = (flag_method in ['adjoint-error','forward-error'])
amrdata.flag_richardson_tol = 3e-3 # suggested if using adjoint-error flag

# Flag for refinement using routine flag2refine:
amrdata.flag2refine = (flag_method in ['adjoint-mag','forward-diff'])
#amrdata.flag2refine_tol = 3e-4 # suggested if using adjoint-mag flag
amrdata.flag2refine_tol = 0.05 # suggested if using forward-diff

# location of adjoint solution, must first be created:
adjointdata.adjoint_outdir = os.path.abspath('adjoint/_output')