コード例 #1
0
ファイル: test_inv.py プロジェクト: TxAnton/LorenzAttractor
    log_scale = True

    for method in methods:
        for inv in range(1, 6):
            # calcs.append((method,inv))
            # res_h.append([])
            #
            # continue
            print("=============================")
            print(f'{method}@{inv}')

            AL1 = Attractor(step=0.0001,
                            num_steps=10000)  # TODO Шаг выставляется тут!
            AL1.set_invariant_params(inv)
            AL1.call_method(method)
            calls = AL1.get_counter()
            print("calls_f: ", calls)
            # Get inv func
            I, err = AL1.get_invariant_err(inv)
            # Cut thirds
            l = int(I.shape[1] * (1.0 / 3.0))
            I = I[:, l:-l]
            err = err[:, l:-l]
            txt = f'{method}@{inv}#{calls}'

            # fig.savefig
            M = np.mean(I[0])
            D = np.std(I[0] - M)
            K, C = lse(I)

            res[str((method, inv))] = [M, D, K, C]
コード例 #2
0
from attractor import Attractor

if __name__ == "__main__":
    # Euler
    AL1 = Attractor()
    AL1.call_method("EUL1")
    AL1.show("img/Euler", "Euler's method", False, True)
    print("Вызовов EUL1 f: ", AL1.get_counter())

    # Midpoint
    AL2 = Attractor()
    AL2.call_method("MIDP2")
    AL2.show("img/Midpoint", "Midpoint method", False, True)
    print("Вызовов MIDP2 f: ", AL2.get_counter())

    # RK4
    AL3 = Attractor()
    AL3.call_method("RK4")
    AL3.show("img/RK4", "RK4 method", False, True)
    print("Вызовов RK4 f: ", AL3.get_counter())

    # Adams Bashforts
    AL4 = Attractor()
    AL4.call_method("AB4")
    AL4.show("img/Adams_Bashforts_", "Adams Bashfort method", False, True)
    print("Вызовов AB4 f: ", AL4.get_counter())

    # Adams Moulton 5
    AL5 = Attractor()
    AL5.call_method("ABM5")
    AL5.show("img/Adams_Bashforts_Moulton", "Adams-Bashfort-Moulton", False, True)