From 62026377c342500f29edb5b646638e9f6720b3a8 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Fri, 3 Nov 2023 16:41:36 +0100 Subject: [PATCH] Fix format. --- oscillator/python/oscillator.py | 2 +- oscillator/python/problemDefinition.py | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/oscillator/python/oscillator.py b/oscillator/python/oscillator.py index 8af6117ba..16f11f9a6 100644 --- a/oscillator/python/oscillator.py +++ b/oscillator/python/oscillator.py @@ -120,7 +120,7 @@ class Participant(Enum): # compute time step size for this time step precice_dt = participant.get_max_time_step_size() dt = np.min([precice_dt, my_dt]) - read_time = (1-alpha_f) * dt + read_time = (1 - alpha_f) * dt read_data = participant.read_data(mesh_name, read_data_name, vertex_ids, read_time) f = read_data[0] diff --git a/oscillator/python/problemDefinition.py b/oscillator/python/problemDefinition.py index e1e4dd31c..b0ac2aea3 100644 --- a/oscillator/python/problemDefinition.py +++ b/oscillator/python/problemDefinition.py @@ -3,22 +3,23 @@ class SpringLeft: - k = 4*np.pi**2 + k = 4 * np.pi**2 class SpringMiddle: - k = 16*(np.pi**2) + k = 16 * (np.pi**2) class SpringRight: - k = 4*np.pi**2 + k = 4 * np.pi**2 class MassLeft: # mass m = 1 - # initial conditions (the way how we currently compute the analytical solution allows arbitrary u0, but requires v0 = 0) + # initial conditions (the way how we currently compute the analytical + # solution allows arbitrary u0, but requires v0 = 0) u0 = 1.0 v0 = 0.0 @@ -29,7 +30,8 @@ class MassRight: # mass m = 1 - # initial conditions (the way how we currently compute the analytical solution allows arbitrary u0, but requires v0 = 0) + # initial conditions (the way how we currently compute the analytical + # solution allows arbitrary u0, but requires v0 = 0) u0 = 0.0 v0 = 0.0 @@ -40,12 +42,12 @@ class MassRight: M = np.array([ [MassLeft.m, 0], [0, MassRight.m] - ]) +]) # Stiffness matrix K = np.array([ [SpringLeft.k + SpringMiddle.k, -SpringMiddle.k], [-SpringMiddle.k, SpringRight.k + SpringMiddle.k] - ]) +]) # system: # m ddu + k u = f @@ -58,7 +60,9 @@ class MassRight: c = np.linalg.solve(eigenvectors, [MassLeft.u0, MassRight.u0]) MassLeft.u_analytical = lambda t: c[0] * A[0] * np.cos(omega[0] * t) + c[1] * A[1] * np.cos(omega[1] * t) -MassLeft.v_analytical = lambda t: -c[0] * A[0] * omega[0] * np.sin(omega[0] * t) - c[1] * A[1] * omega[1] * np.sin(omega[1] * t) +MassLeft.v_analytical = lambda t: -c[0] * A[0] * omega[0] * \ + np.sin(omega[0] * t) - c[1] * A[1] * omega[1] * np.sin(omega[1] * t) MassRight.u_analytical = lambda t: c[0] * B[0] * np.cos(omega[0] * t) + c[1] * B[1] * np.cos(omega[1] * t) -MassRight.v_analytical = lambda t: -c[0] * B[0] * omega[0] * np.sin(omega[0] * t) - c[1] * B[1] * omega[1] * np.sin(omega[1] * t) \ No newline at end of file +MassRight.v_analytical = lambda t: -c[0] * B[0] * omega[0] * \ + np.sin(omega[0] * t) - c[1] * B[1] * omega[1] * np.sin(omega[1] * t)