Describe rootfinding example in README. #1070

This commit is contained in:
Penn, John M 047828115 2020-10-29 13:00:27 -05:00
parent 23f04ffea2
commit b9f25646e8
2 changed files with 24 additions and 2 deletions

View File

@ -54,8 +54,11 @@ int main ( int argc, char* argv[]) {
double dt = 0.01;
double t = 0.0;
SA::RK2Integrator integ(dt, 6, state_var_p, state_var_p, calc_derivs, NULL);
RootFinder root_finder(0.00000000001, Negative);
integ.add_Rootfinder(&root_finder, &impact);
// Uncomment the following two lines to have the RootFinder detect impact.
// RootFinder root_finder(0.00000000001, Negative);
// integ.add_Rootfinder(&root_finder, &impact);
init_state(cannon);
print_header();
print_state( t, cannon);

View File

@ -9,3 +9,22 @@ $ python plot_trajectory.py
```
![Cannon](images/Cannon.png)
```
$ make
$ ./Cannonball
```
Next edit, and uncomment the indicated lines, recompile, and run. You should see:
```
5.070, 219.5374398594, 0.6674655000, 43.3012701892, -24.7367000000, 0.0000000000, -9.8100000000
5.080, 219.9704525612, 0.4196080000, 43.3012701892, -24.8348000000, 0.0000000000, -9.8100000000
5.090, 220.4034652631, 0.1707695000, 43.3012701892, -24.9329000000, 0.0000000000, -9.8100000000
---------------------------------------------------------------
Impact at t = 5.0968399592 x = 220.6996441856 y = 0.0000000000.
---------------------------------------------------------------
5.100, 220.6996441856, 0.0000000001, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000
5.110, 220.6996441856, 0.0000000001, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000
5.120, 220.6996441856, 0.0000000001, 0.0000000000, 0.0000000000, 0.0000000000, 0.0000000000
```