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

Updating step size control #483

Merged
merged 47 commits into from
Mar 26, 2015
Merged

Updating step size control #483

merged 47 commits into from
Mar 26, 2015

Conversation

hadjimy
Copy link
Member

@hadjimy hadjimy commented Dec 16, 2014

This PR changes the step-size control for LMMs and revises the way the step-size is updated at each step for RK methods.

There is still some work currently in process to make the code more efficient and robust.

Note there is a test that fails in parallel (acoustics_2d_homogeneous) when SSPLMM32 is used, but could not reproduce that in my machine (where all tests pass).

@mandli
Copy link
Member

mandli commented Dec 17, 2014

Any ideas on the test failure front? It would be nice to merge this in but I really don't think we should if the tests fail even if it is not reproducible.

@hadjimy
Copy link
Member Author

hadjimy commented Dec 18, 2014

No it is unclear why this single test fails. I run nosetests on both my mac and Ubuntu with no errors.
@mandli Could you run nosetests in your machine?
We shouldn't merge it before figuring out was it going wrong.
Note that SSPLMM32 is used in acoustics_2d_variable (and other examples) with no errors.

@mandli
Copy link
Member

mandli commented Dec 20, 2014

The tests pass although PETSc does emit an error I have not seen before

[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.

I am not sure if that's anything to do with the problem you are seeing as I cannot figure out which test is actually emitting the error and why it does not cause the test to fail.

@ketch
Copy link
Member

ketch commented Dec 21, 2014

@mandli I believe you are running nosetests from clawpack/pyclaw. Run it from clawpack/pyclaw/examples. See #489.

@mandli
Copy link
Member

mandli commented Dec 21, 2014

@ketch thanks for tracking that one down.

@hadjimy
Copy link
Member Author

hadjimy commented Dec 22, 2014

I can reproduce Travis error message when running
mpirun -n 4 nosetests:

======================================================================
ERROR: examples.acoustics_2d_homogeneous.acoustics_2d({'time_integrator': 'SSPLMM32', 'disable_output': True, 'solver_type': 'sharpclaw'})
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/hadjimy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/hadjimy/Programs/clawpack/clawpack/pyclaw/util.py", line 172, in <lambda>
    test = lambda: test_app(application, verifier, test_kwargs)
  File "/Users/hadjimy/Programs/clawpack/clawpack/pyclaw/util.py", line 258, in test_app
    raise VerifyError(err)
VerifyError: /Users/hadjimy/Programs/clawpack/pyclaw/examples/acoustics_2d_homogeneous/acoustics_2d.py
********************************************************************************
verification function
        def verify(claw):
            """ verifies 2d homogeneous acoustics from a previously verified run """
            import os
            import numpy as np
            from clawpack.pyclaw.util import check_diff


            #grabs parallel results to process 0, None to other processes
            test_q=claw.solution.state.get_q_global()

            if test_q is not None:
                test_pressure = test_q[0,:,:]
                thisdir = os.path.dirname(__file__)
                expected_pressure = np.loadtxt(os.path.join(thisdir,data_filename))
                return check_diff(expected_pressure, test_pressure, reltol=1e-3, 
                                    delta=claw.solution.grid.delta)
            else:
                return

args                 : {'use_petsc': True, 'time_integrator': 'SSPLMM32', 'kernel_language': 'Fortran', 'disable_output': True, 'solver_type': 'sharpclaw'}
norm of expected data: 0.0196003663743
norm of test data    : 0.0195695757644
test error           : 0.000185196027373
reltol  : 0.001
********************************************************************************

-------------------- >> begin captured stdout << ---------------------
{'use_petsc': True, 'time_integrator': 'SSPLMM32', 'kernel_language': 'Fortran', 'disable_output': True, 'solver_type': 'sharpclaw'}

--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
root: INFO: Solution 0 computed for time t=0.000000
root: INFO: Solution 1 computed for time t=0.012000
root: INFO: Solution 2 computed for time t=0.024000
root: INFO: Solution 3 computed for time t=0.036000
root: INFO: Solution 4 computed for time t=0.048000
root: INFO: Solution 5 computed for time t=0.060000
root: INFO: Solution 6 computed for time t=0.072000
root: INFO: Solution 7 computed for time t=0.084000
root: INFO: Solution 8 computed for time t=0.096000
root: INFO: Solution 9 computed for time t=0.108000
root: INFO: Solution 10 computed for time t=0.120000
--------------------- >> end captured logging << ---------------------

Before I was just running nosetests and as @ketch pointed out this does not run any tests in parallel.
I made another branch and tried a bit to see what is going wrong.

In my opinion this error is not caused by the recent changes in step-size control. It is an error related to TVD discretizations (lim_type=1) and I think it has been around for some time.
Note that there are only 3 nosetests to test the lim_type=1 option:

  1. in euler 1d which runs ok
  2. in acoustics 2d variable
  3. in acoustics 2d homogeneous

The error occurs when testing sharpclaw with TVD methods (solver_type=sharpclaw and lim_type=1) because the difference between the computed and reference solution is large (eg. when measured in L1 grid norm). This is not noticeable in acoustics_2d_variable because nosetests check the absolute error with a tolerance 1e-1. However in acoustics 2d_homogeneous nosetests check the relative error and this triggers the error when running in MPI and PETSc.

You can test it out by checking nosetests_petsc from
https://github.com/hadjimy/pyclaw/tree/nosetests_petsc

Then run checking_petsc.sh and observe the error between the expected_pressure and test_pressure when running with WENO and TVD methods. That should have been of order machine precision but when lim_type=1 and use MPI and PETSc, the error is more than 1e-4.

This might be related to errors accumulated at ghost cells or might be more involved and has to do with how TVD methods work in MPI and PETSc.

@@ -22,6 +22,8 @@ def get_cached_max(self):
def set_local_max(self,new_local_max):
self._global_max = new_local_max

def update_global_max(self,new_local_max):
self._global_max = new_local_max
def set_global_max(self,new_global_max):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method is identical to that of the parent function, so there is no need to explicitly duplicate it here. It will be automatically inherited.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I removed that method. Also set_local_max is not currently being used.

@hadjimy
Copy link
Member Author

hadjimy commented Jan 11, 2015

@ketch Do you think we should test LMM only with WENO and merge this PR?

@mandli
Copy link
Member

mandli commented Feb 17, 2015

Excellent, I wanted to make sure as we had talked about making this change before. I would say we should merge this then unless someone else has objections.

@hadjimy
Copy link
Member Author

hadjimy commented Feb 17, 2015

There is some space for improvements, for example using the already saved function evaluations for a general LMM method and I recently discovered that we are using an additional register for the SSP104 method. But these are smaller changes and can be included in a forthcoming PR.

@mandli
Copy link
Member

mandli commented Feb 17, 2015

Yeah, I would say merge this and add those as upcoming enhancements. There are a few spots that I think could be PEP8ized as well but that's pretty minor.

@ketch
Copy link
Member

ketch commented Feb 19, 2015

Thanks, @mandli. @hadjimy is investigating some funny observed behavior of the initial step sizes before we merge this.

Also:
- General LMM now uses previously saved function evaluations
- rename self.deltaq to self.dq_dt
- update accept_reject_step and get_dt_new
@hadjimy
Copy link
Member Author

hadjimy commented Feb 23, 2015

I have fixed the issue regarding the step-size choice for starting methods and also make general LMM use previous function evaluations.

ketch and others added 13 commits February 24, 2015 14:34
…nto step-size_control

* 'step-size_control' of git://github.com/hadjimy/pyclaw:
  Update nosetests.
  Correct step-size choice for starting methods of LMMs.

Conflicts:
	src/pyclaw/sharpclaw/solver.py
This avoids some messy things and ensures that the step size rejection
is determined using the right CFL number.
Also:
- Add SSPLMM53
- Edit documentation
- Correct omega3 in SSPLMM43.
- Add SSP coefficients for 3rd order SSPLMM.
- Don't pass cfl to accept_reject_step().
- Make accept_step local variable in accept_reject_step().
- Use [:] instead of copy.
- Edit documentation/remove redundant comments.
self.step().
- Make SSPLMM work with constant step size.
- Make a single routine to update saved info for LMMs at the beggining
of step() function.
- Step size for starting values is chosen inside get_dt_new() and when
the linear multistep part is active, the step size is set in set_dt().
- Add routine for the additional conditions for 3rd order SSPLMM and
correct step-size update in case the conditions are violated.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.44%) to 27.2% when pulling eb7d715 on hadjimy:step-size_control into 40a7249 on clawpack:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.71%) to 27.47% when pulling deb71d0 on hadjimy:step-size_control into 40a7249 on clawpack:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.72%) to 27.48% when pulling 7dfd2ed on hadjimy:step-size_control into 40a7249 on clawpack:master.

@ketch
Copy link
Member

ketch commented Mar 26, 2015

This looks ready to merge. It is great that now the 2nd-order methods allow for any number of steps and that there are tests for 4 different SSP LMMs. Nice work @hadjimy !

ketch added a commit that referenced this pull request Mar 26, 2015
@ketch ketch merged commit e34ec5f into clawpack:master Mar 26, 2015
@ketch
Copy link
Member

ketch commented Mar 26, 2015

@mandli and @rjleveque PyClaw is ready for the 5.3 release. There is a small additional refactoring that we hope to get done in time, but if you want to generate a release candidate now, that is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants