def main(): global motion_r, motion_a # Get the affected set of particles (it is also an identifier on the motion) motion_iset = aqua.get("motion_iset") # Check if they were not already set, eventually copying them from the # current motion state. if motion_r is None or motion_a is None: n_sets = aqua.get("n_sets") motion_r = [None] * n_sets motion_a = [None] * n_sets if motion_r[motion_iset] is None: motion_r[motion_iset] = aqua.get("motion_r") if motion_a[motion_iset] is None: motion_a[motion_iset] = aqua.get("motion_a") # Set the backuped state aqua.set("motion_r_in", motion_r[motion_iset]) aqua.set("motion_a_in", motion_a[motion_iset]) # Backuo the new state variables motion_r[motion_iset] = np.copy(aqua.get("motion_r")) motion_a[motion_iset] = np.copy(aqua.get("motion_a")) return True
def main(): global DT, Theta, dTheta, ddTheta, F ddTheta_in = ddTheta # Backup for the predictor-corrector # Predictor Theta, dTheta = predictor(DT, Theta, dTheta, ddTheta) # Get the new time and time step t = aqua.get("t") dt = aqua.get("dt") # Get new mass position (and experimental resulting angle) xi = np.interp(t, T, XI) dXi = np.interp(t, T, DXI) exp_theta = np.interp(t, T, THETA) # Compute ddTheta M = aqua.get("forces_M")[0] ddTheta = angularForce(M, xi, dXi, Theta, dTheta) # Corrector dTheta = corrector(dt, dTheta, ddTheta, ddTheta_in) DT = dt # Store it for the predictor in the following time step # Send the data to SPH a = np.zeros(4, dtype=np.float32) a[0] = Theta aqua.set("motion_a", a) dadt = np.zeros(4, dtype=np.float32) dadt[0] = dTheta aqua.set("motion_dadt", dadt) # Write output F.write('{}\t{}\t{}\t{}\t{}\t{}\n'.format(t, xi, exp_theta, np.degrees(a[0]), np.degrees(dadt[0]), M)) F.flush() return True
def main(): global DT, Theta, dTheta, ddTheta, F ddTheta_in = ddTheta # Backup for the predictor-corrector # Predictor Theta, dTheta = predictor(DT, Theta, dTheta, ddTheta) # Get the new time and time step t = aqua.get("t") dt = aqua.get("dt") # Get new mass position (and experimental resulting angle) xi = np.interp(t, T, XI) dXi = np.interp(t, T, DXI) exp_theta = np.interp(t, T, THETA) # Compute ddTheta M = aqua.get("forces_M")[0] ddTheta = angularForce(M, xi, dXi, Theta, dTheta) # Corrector dTheta = corrector(dt, dTheta, ddTheta, ddTheta_in) DT = dt # Store it for the predictor in the following time step # Send the data to SPH a = np.zeros(4, dtype=np.float32) a[0] = Theta aqua.set("motion_a", a) dadt = np.zeros(4, dtype=np.float32) dadt[0] = dTheta aqua.set("motion_dadt", dadt) # Write output F.write('{}\t{}\t{}\t{}\t{}\t{}\n'.format( t, xi, exp_theta, np.degrees(a[0]), np.degrees(dadt[0]), M)) F.flush() return True
def main(): # Get the time instant t = aqua.get("t") # Interpolate the data a = np.zeros(4, dtype=np.float32) a[0] = np.radians(np.interp(t, T, A)) dadt = np.zeros(4, dtype=np.float32) dadt[0] = np.radians(np.interp(t, T, DADT)) # Send it to AQUAgpusph aqua.set("motion_a", a) aqua.set("motion_dadt", dadt) return True
def main(): dt = aqua.get("dt") for e_name in E_NAMES: # Get the data e = aqua.get('energy_' + e_name) dedt = aqua.get('energy_d' + e_name + 'dt') dedt_in = aqua.get('energy_d' + e_name + 'dt_in') # Perform the corrector e += 0.5 * dt * (dedt - dedt_in) aqua.set('energy_' + e_name, e) return True
def main(): dt = aqua.get("dt") for e_name in E_NAMES: # Get the data e = aqua.get('energy_' + e_name) dedt = aqua.get('energy_d' + e_name + 'dt') # Perform the predictor e += dt * dedt aqua.set('energy_' + e_name, e) # Store the energy variation for the Corrector aqua.set('energy_d' + e_name + 'dt_in', dedt) return True
def main(): # Get the time instant t = aqua.get("t") # Interpolate the data r = np.zeros(2, dtype=np.float32) r[0] = np.interp(t, T, X) u = np.zeros(2, dtype=np.float32) u[0] = np.interp(t, T, U) dudt = np.zeros(2, dtype=np.float32) dudt[0] = np.interp(t, T, DUDT) # Send it to AQUAgpusph aqua.set("motion_r", r) aqua.set("motion_drdt", u) aqua.set("motion_ddrddt", dudt) # Write output F.write('{}\t{}\t{}\t{}\n'.format(t, r[0], u[0], dudt[0])) F.flush() return True