|
| 1 | +from __future__ import division |
| 2 | + |
| 3 | +import numpy as np |
| 4 | + |
| 5 | +from pySDC.implementations.problem_classes.OuterSolarSystem import outer_solar_system |
| 6 | +from pySDC.implementations.datatype_classes.particles import particles, acceleration |
| 7 | +from pySDC.core.Errors import ParameterError |
| 8 | + |
| 9 | + |
| 10 | +# noinspection PyUnusedLocal |
| 11 | +class full_solar_system(outer_solar_system): |
| 12 | + """ |
| 13 | + Example implementing the full solar system problem |
| 14 | + """ |
| 15 | + |
| 16 | + def __init__(self, problem_params, dtype_u, dtype_f): |
| 17 | + """ |
| 18 | + Initialization routine |
| 19 | +
|
| 20 | + Args: |
| 21 | + problem_params (dict): custom parameters for the example |
| 22 | + dtype_u: particle data type (will be passed parent class) |
| 23 | + dtype_f: acceleration data type (will be passed parent class) |
| 24 | + """ |
| 25 | + |
| 26 | + if 'sun_only' not in problem_params: |
| 27 | + problem_params['sun_only'] = False |
| 28 | + |
| 29 | + # these parameters will be used later, so assert their existence |
| 30 | + essential_keys = [] |
| 31 | + for key in essential_keys: |
| 32 | + if key not in problem_params: |
| 33 | + msg = 'need %s to instantiate problem, only got %s' % (key, str(problem_params.keys())) |
| 34 | + raise ParameterError(msg) |
| 35 | + |
| 36 | + # invoke parant's class (!) super init, passing nparts, dtype_u and dtype_f |
| 37 | + super(outer_solar_system, self).__init__((3, 10), dtype_u, dtype_f, problem_params) |
| 38 | + |
| 39 | + # gravitational constant |
| 40 | + self.G = 2.95912208286E-4 |
| 41 | + |
| 42 | + def u_exact(self, t): |
| 43 | + """ |
| 44 | + Routine to compute the exact/initial trajectory at time t |
| 45 | +
|
| 46 | + Args: |
| 47 | + t (float): current time |
| 48 | + Returns: |
| 49 | + dtype_u: exact/initial position and velocity |
| 50 | + """ |
| 51 | + assert t == 0.0, 'error, u_exact only works for the initial time t0=0' |
| 52 | + me = particles(self.init) |
| 53 | + |
| 54 | + # initial positions and velocities taken from |
| 55 | + # https://www.aanda.org/articles/aa/full/2002/08/aa1405/aa1405.right.html |
| 56 | + me.pos.values[:, 0] = [0.0, 0.0, 0.0] |
| 57 | + me.pos.values[:, 1] = [-2.503321047836E-01, +1.873217481656E-01, +1.260230112145E-01] |
| 58 | + me.pos.values[:, 2] = [+1.747780055994E-02, -6.624210296743E-01, -2.991203277122E-01] |
| 59 | + me.pos.values[:, 3] = [-9.091916173950E-01, +3.592925969244E-01, +1.557729610506E-01] |
| 60 | + me.pos.values[:, 4] = [+1.203018828754E+00, +7.270712989688E-01, +3.009561427569E-01] |
| 61 | + me.pos.values[:, 5] = [+3.733076999471E+00, +3.052424824299E+00, +1.217426663570E+00] |
| 62 | + me.pos.values[:, 6] = [+6.164433062913E+00, +6.366775402981E+00, +2.364531109847E+00] |
| 63 | + me.pos.values[:, 7] = [+1.457964661868E+01, -1.236891078519E+01, -5.623617280033E+00] |
| 64 | + me.pos.values[:, 8] = [+1.695491139909E+01, -2.288713988623E+01, -9.789921035251E+00] |
| 65 | + me.pos.values[:, 9] = [-9.707098450131E+00, -2.804098175319E+01, -5.823808919246E+00] |
| 66 | + |
| 67 | + me.vel.values[:, 0] = [0.0, 0.0, 0.0] |
| 68 | + me.vel.values[:, 1] = [-2.438808424736E-02, -1.850224608274E-02, -7.353811537540E-03] |
| 69 | + me.vel.values[:, 2] = [+2.008547034175E-02, +8.365454832702E-04, -8.947888514893E-04] |
| 70 | + me.vel.values[:, 3] = [-7.085843239142E-03, -1.455634327653E-02, -6.310912842359E-03] |
| 71 | + me.vel.values[:, 4] = [-7.124453943885E-03, +1.166307407692E-02, +5.542098698449E-03] |
| 72 | + me.vel.values[:, 5] = [-5.086540617947E-03, +5.493643783389E-03, +2.478685100749E-03] |
| 73 | + me.vel.values[:, 6] = [-4.426823593779E-03, +3.394060157503E-03, +1.592261423092E-03] |
| 74 | + me.vel.values[:, 7] = [+2.647505630327E-03, +2.487457379099E-03, +1.052000252243E-03] |
| 75 | + me.vel.values[:, 8] = [+2.568651772461E-03, +1.681832388267E-03, +6.245613982833E-04] |
| 76 | + me.vel.values[:, 9] = [+3.034112963576E-03, -1.111317562971E-03, -1.261841468083E-03] |
| 77 | + |
| 78 | + # masses relative to the sun taken from |
| 79 | + # https://en.wikipedia.org/wiki/Planetary_mass#Values_from_the_DE405_ephemeris |
| 80 | + me.m[0] = 1.0 # Sun |
| 81 | + me.m[1] = 0.1660100 * 1E-06 # Mercury |
| 82 | + me.m[2] = 2.4478383 * 1E-06 # Venus |
| 83 | + me.m[3] = 3.0404326 * 1E-06 # Earth+Moon |
| 84 | + me.m[4] = 0.3227151 * 1E-06 # Mars |
| 85 | + me.m[5] = 954.79194 * 1E-06 # Jupiter |
| 86 | + me.m[6] = 285.88600 * 1E-06 # Saturn |
| 87 | + me.m[7] = 43.662440 * 1E-06 # Uranus |
| 88 | + me.m[8] = 51.513890 * 1E-06 # Neptune |
| 89 | + me.m[9] = 0.0073960 * 1E-06 # Pluto |
| 90 | + |
| 91 | + return me |
0 commit comments