コード例 #1
0
ファイル: mp_integrator.py プロジェクト: ipelupessy/yaravi
 def commit_particles(self):
     kwargs = self.kwargs.copy()
     if "dps" not in kwargs:
         kwargs["dps"] = max(int(-mp.log10(self.target_error) + 6), 15)
     self.integrator = mp_adaptive_bulirschStoer(self.target_error,
                                                 **kwargs)
     self.time = mp.mpf(self.time)
コード例 #2
0
def check_kick(Ns=None):
    dps = 64
    results = {
        16:
        '0.5280968268833149585365524469736931751421937461245719231626600116459',
        50:
        '0.9570351506440379530178266489555425661480746175752162677540570048262',
        64:
        '-0.7561747845694916564830825081707286817639452371097957709612294389958',
        150:
        "-0.09344415268620983521705314736452944414180898050922914284511780006364",
        256:
        "-0.6293985589493140191821290296902117972778559732348390605690993188598",
        350:
        "0.735469970603869347834820970508731867404741985456426980852100139499",
        512:
        "0.9517024891436366308665374005000831926596595154320406804913855436092"
    }
    check = True
    if Ns is None: Ns = results.keys()
    for N in Ns:
        for p in ["multi", "amuse", "pp", "local", "proc"]:
            h = time_kick(N=N, processor=p, dps=dps)
            hr = h.__repr__()
            if hr.find(results[N]) >= 0:
                pass


#          print p+" ok"
            else:
                d = abs(h - mp.mpf(results[N])) / h
                print N, p + " mismatch, got:", hr, len(hr), float(
                    abs(mp.log10(d)))
                if d > 10**-dps: check = False
    return check
コード例 #3
0
def check_BS_test_long(Ns=None):
    dps = 64
    results = {
        8:
        "0.5136878528165021745895011935069557781577860512538393575491621445983",
        16:
        "0.1779243262721065866057229914813588355640085932912539562135719013325"
    }
    if Ns is None: Ns = results.keys()
    check = True
    for N in Ns:
        for p in ["multi", "amuse", "pp", "local", "proc"]:
            h = BS_test(N=N,
                        processor=p,
                        dps=dps,
                        tend=1.,
                        prec='1.e-32',
                        res="x")
            hr = h.__repr__()
            if hr.find(results[N][:dps - 5]) >= 0:
                pass


#          print p+" ok"
            else:
                d = abs(h - mp.mpf(results[N])) / h
                print d
                print N, p + " mismatch, got:", hr, len(hr), float(
                    abs(mp.log10(d)))
                if abs(d) > 10**(-dps + 5): check = False
    return check
コード例 #4
0
def check_BS_test(Ns=None):
    dps = 64
    results = {
        16:
        "-0.2097788238899595006650143725272014434855335456003604589938999139641",
        32:
        "-0.2618649325481234815725778388341436310813732608134373611530832641849"
    }
    if Ns is None: Ns = results.keys()
    check = True
    for N in Ns:
        for p in ["multi", "amuse", "pp", "local", "proc"]:
            h = BS_test(N=N, processor=p, dps=dps)
            hr = h.__repr__()
            if hr.find(results[N][:dps - 5]) >= 0:
                pass


#          print p+" ok"
            else:
                d = abs((h - mp.mpf(results[N])) / h)
                print d, h
                print N, p + " mismatch, got:", hr, len(hr), float(
                    abs(mp.log10(d)))
                if abs(d) > 10**(-dps + 5): check = False
    return check
コード例 #5
0
ファイル: mp_integrator.py プロジェクト: ipelupessy/yaravi
    def commit_particles(self):
        self.target_error1 = self.initial_target_error / self.error_factor
        self.target_error2 = self.initial_target_error

        kwargs1 = self.kwargs.copy()
        kwargs2 = self.kwargs.copy()

        if "dps" not in kwargs1:
            kwargs1["dps"] = max(int(-mp.log10(self.target_error1) + 6), 15)
        if "dps" not in kwargs2:
            kwargs2["dps"] = max(int(-mp.log10(self.target_error1) + 6), 15)

        self.integrator1 = mp_adaptive_bulirschStoer(self.target_error1,
                                                     **kwargs1)
        self.integrator2 = mp_adaptive_bulirschStoer(self.target_error2,
                                                     **kwargs2)

        self.checkpoint = copy_particles(self.particles)
        self.particles1 = self.particles
        self.particles2 = copy_particles(self.particles1)
        self.checkpoint_time = self.time

        self.wallclock1 = 0
        self.wallclock2 = 0
コード例 #6
0
ファイル: mp_integrator.py プロジェクト: ipelupessy/yaravi
    def evolve(self, tend):
        dt = tend - self.time

        if dt <= 0:
            return

        t1 = time.time()
        self.integrator1.evolve(self.particles1, dt)
        t2 = time.time()
        self.wallclock1 += t2 - t1
        self.integrator2.evolve(self.particles2, dt)
        t3 = time.time()
        self.wallclock2 += t3 - t2

        print "timing:", t2 - t1, t3 - t2, ", ratio:", (t2 - t1) / (t3 - t2)

        error = self.error_condition(self.particles1, self.particles2)

        while error:

            self.integrator2 = self.integrator1
            self.particles2 = self.particles1
            self.target_error2 = self.target_error1
            self.wallclock2 = self.wallclock1

            self.target_error1 = self.target_error1 / self.error_factor
            kwargs1 = self.kwargs.copy()

            if "dps" not in kwargs1:
                kwargs1["dps"] = max(int(-mp.log10(self.target_error1) + 6),
                                     15)

            self.integrator1 = mp_adaptive_bulirschStoer(
                self.target_error1, **kwargs1)
            self.particles1 = copy_particles(self.checkpoint)
            t1 = time.time()
            self.integrator1.evolve(self.particles1,
                                    tend - self.checkpoint_time)
            t2 = time.time()
            self.wallclock1 += t2 - t1
            print "timing (totals):", self.wallclock1, self.wallclock2, self.wallclock1 / self.wallclock2

            error = self.error_condition(self.particles1, self.particles2)

        self.particles = self.particles1
        self.time = tend