Skip to content

Commit d67814c

Browse files
committed
testing and docs
1 parent a24d594 commit d67814c

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

docs/source/projects/doc_fput.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Full code: `pySDC/projects/Hamiltonian/fput.py <https://github.com/Parallel-in-Time/pySDC/blob/master/pySDC/projects/Hamiltonian/fput.py>`_
2+
3+
.. literalinclude:: ../../../pySDC/projects/Hamiltonian/fput.py
4+
5+
Results:
6+
7+
.. literalinclude:: ../../../fput_out.txt
8+
9+
.. image:: ../../../data/fput_hamiltonian.png
10+
:scale: 100 %
11+
.. image:: ../../../data/fput_positions.png
12+
:scale: 100 %
13+
.. image:: ../../../data/fput_energy.png
14+
:scale: 100 %

pySDC/projects/Hamiltonian/README.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,14 @@ Coarsening can be done using only the sun for computing the acceleration.
2727
Note how PFASST works very well for the outer solar system problem, but not so well for the full solar system problem.
2828
Here, over 15 iterations are required in the mean, while SDC and MLSDC require only about 5 per step.
2929

30-
.. include:: doc_solar_system.rst
30+
.. include:: doc_solar_system.rst
31+
32+
Fermi-Pasta-Ulam-Tsingou problem
33+
--------------------------------
34+
35+
This is the famous FPUT problem, one of the first numerical simulation done in physics.
36+
The basis for this setup can be found `here <http://www.scholarpedia.org/article/Fermi-Pasta-Ulam_nonlinear_lattice_oscillations>`_ and we implement this in the ``FermiPastaUlamTsingou`` problem class.
37+
Due to time limitations in the CI environment, we only run the first few steps and not until Tend=10000.
38+
Note that we run MLSDC here, since PFASST does not seem to converge easily.
39+
40+
.. include:: doc_fput.rst

pySDC/projects/Hamiltonian/fput.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def setup_fput():
3434
# initialize sweeper parameters
3535
sweeper_params = dict()
3636
sweeper_params['collocation_class'] = CollGaussLobatto
37-
sweeper_params['num_nodes'] = [5]
37+
sweeper_params['num_nodes'] = [5, 3]
3838
sweeper_params['spread'] = False
3939

4040
# initialize problem parameters for the Penning trap
@@ -78,7 +78,9 @@ def run_simulation():
7878
description, controller_params = setup_fput()
7979
# set time parameters
8080
t0 = 0.0
81-
Tend = 5000.0
81+
# set this to 10000 to reproduce the picture in
82+
# http://www.scholarpedia.org/article/Fermi-Pasta-Ulam_nonlinear_lattice_oscillations
83+
Tend = 250.0
8284
num_procs = 1
8385

8486
f = open('fput_out.txt', 'w')
@@ -126,12 +128,12 @@ def run_simulation():
126128

127129
# get runtime
128130
timing_run = sort_stats(filter_stats(stats, type='timing_run'), sortby='time')[0][1]
129-
out = '... took %s seconds to run this.' % timing_run
131+
out = '... took %6.4f seconds to run this.' % timing_run
130132
f.write(out + '\n')
131133
print(out)
132134
f.close()
133135

134-
# assert np.mean(niters) <= maxmeaniter, 'Mean number of iterations is too high, got %s' % np.mean(niters)
136+
assert np.mean(niters) <= 3.0, 'Mean number of iterations is too high, got %s' % np.mean(niters)
135137

136138
fname = 'data/fput.dat'
137139
f = open(fname, 'wb')
@@ -176,7 +178,7 @@ def show_results(cwd=''):
176178
err_ham = ham[-1]
177179
plt_helper.plt.semilogy(time, ham, '-', lw=1, label='Iter ' + str(k))
178180
print(err_ham)
179-
# assert err_ham < 7.5E-15, 'Error in the Hamiltonian is too large for %s, got %s' % (prob, err_ham)
181+
assert err_ham < 1E-10, 'Error in the Hamiltonian is too large for %s, got %s' % (prob, err_ham)
180182

181183
plt_helper.plt.xlabel('Time')
182184
plt_helper.plt.ylabel('Error in Hamiltonian')
@@ -197,7 +199,6 @@ def show_results(cwd=''):
197199
plt_helper.newfig(textwidth=238.96, scale=0.89)
198200

199201
# Rearrange data for easy plotting
200-
201202
for mode in result[0][1].keys():
202203
time = [item[0] for item in result]
203204
energy = [item[1][mode] for item in result]
@@ -246,5 +247,6 @@ def main():
246247
run_simulation()
247248
show_results()
248249

250+
249251
if __name__ == "__main__":
250252
main()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pySDC.projects.Hamiltonian.fput import main
2+
3+
def test_main():
4+
main()

0 commit comments

Comments
 (0)