Skip to content

Commit 5cf10a3

Browse files
committed
fixes for solar system problem, WIP
1 parent c64e391 commit 5cf10a3

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

pySDC/implementations/sweeper_classes/verlet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,8 @@ def integrate(self):
145145
# get current level and problem description
146146
L = self.level
147147
P = L.prob
148-
149148
# create new instance of dtype_u, initialize values with 0
150149
p = []
151-
152150
for m in range(1, self.coll.num_nodes + 1):
153151
p.append(P.dtype_u(P.init, val=0))
154152

@@ -184,6 +182,8 @@ def compute_end_point(self):
184182
for m in range(self.coll.num_nodes):
185183
L.uend.pos += L.dt * (L.dt * self.qQ[m] * L.f[m + 1]) + L.dt * self.coll.weights[m] * L.u[0].vel
186184
L.uend.vel += L.dt * self.coll.weights[m] * L.f[m + 1]
185+
L.uend.m = L.u[0].m
186+
L.uend.q = L.u[0].q
187187
# add up tau correction of the full interval (last entry)
188188
if L.tau is not None:
189189
L.uend += L.tau[-1]

pySDC/implementations/transfer_classes/TransferParticles_NoCoarse.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pySDC.core.SpaceTransfer import space_transfer
2-
from pySDC.implementations.datatype_classes.particles import particles, fields
2+
from pySDC.implementations.datatype_classes.particles import particles, fields, acceleration
33
from pySDC.core.Errors import TransferError
44

55

@@ -35,6 +35,8 @@ def restrict(self, F):
3535
G = particles(F)
3636
elif isinstance(F, fields):
3737
G = fields(F)
38+
elif isinstance(F, acceleration):
39+
G = acceleration(F)
3840
else:
3941
raise TransferError("Unknown type of fine data, got %s" % type(F))
4042
return G
@@ -51,6 +53,8 @@ def prolong(self, G):
5153
F = particles(G)
5254
elif isinstance(G, fields):
5355
F = fields(G)
56+
elif isinstance(G, acceleration):
57+
F = acceleration(G)
5458
else:
5559
raise TransferError("Unknown type of coarse data, got %s" % type(G))
5660
return F

pySDC/projects/Hamiltonian/solar_system.py

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

3939
# initialize problem parameters for the Penning trap
4040
problem_params = dict()
@@ -59,7 +59,7 @@ def setup_outer_solar_system():
5959
description['sweeper_params'] = sweeper_params
6060
description['level_params'] = level_params
6161
description['step_params'] = step_params
62-
# description['space_transfer_class'] = particles_to_particles
62+
description['space_transfer_class'] = particles_to_particles
6363

6464
return description, controller_params
6565

@@ -77,8 +77,8 @@ def run_simulation(prob=None):
7777
description, controller_params = setup_outer_solar_system()
7878
# set time parameters
7979
t0 = 0.0
80-
Tend = 100000.0
81-
num_procs = 1
80+
Tend = 10000.0
81+
num_procs = 100
8282
else:
8383
raise NotImplemented('Problem type not implemented, got %s' % prob)
8484

@@ -118,7 +118,7 @@ def show_results(prob=None, cwd=''):
118118
for k, v in extract_stats.items():
119119
result[k.iter].append((k.time, v))
120120
for k, v in result.items():
121-
# assert k <= 6, 'Number of iterations is too high for %s, got %s' % (prob, k)
121+
assert k <= 4, 'Number of iterations is too high for %s, got %s' % (prob, k)
122122
result[k] = sorted(result[k], key=lambda x: x[0])
123123

124124
plt_helper.mpl.style.use('classic')
@@ -131,8 +131,7 @@ def show_results(prob=None, cwd=''):
131131
ham = [item[1] for item in v]
132132
err_ham = ham[-1]
133133
plt_helper.plt.semilogy(time, ham, '-', lw=1, label='Iter ' + str(k))
134-
135-
# assert err_ham < 2.3E-08, 'Error in the Hamiltonian is too large for %s, got %s' % (prob, err_ham)
134+
assert err_ham < 3.0E-15, 'Error in the Hamiltonian is too large for %s, got %s' % (prob, err_ham)
136135

137136
plt_helper.plt.xlabel('Time')
138137
plt_helper.plt.ylabel('Error in Hamiltonian')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pySDC.projects.Hamiltonian.solar_system import main
2+
3+
def test_main():
4+
main()

0 commit comments

Comments
 (0)