def calibration_driver(omega): """ used for calibrating. forces are obtained from it. """ return dyn.Driver( dyn.Q([True, True, True, True, True, True, True]), dyn.Q([ dyn.const(omega), dyn.const(omega), dyn.const(0), dyn.const(0), dyn.const(0), dyn.const(0), dyn.const(0) ]))
def elastically_clamped_driver(driving_forces, friction_func, omega, tau_A, k_a): """ clamping via force """ (q_phi_l, q_phi_r, q_amp_l, q_amp_r) = driving_forces return dyn.Driver( dyn.Q([False, False, False, False, True, True, False]), dyn.Q([ lambda q: q_phi_l(q.phase_left), lambda q: q_phi_r(q.phase_right), lambda q: dyn.bordered_stiffness( q.phase_left, q.amplitude_left, q_amp_l, friction_func, tau_A, omega), lambda q: dyn.bordered_stiffness( q.phase_right, q.amplitude_right, q_amp_r, friction_func, tau_A, omega), dyn.const(0), dyn.const(0), lambda q: -k_a * q.orientation ]))
def free_driver_without_amplitude(driving_forces, friction_func, omega, phase_force_addition=(dyn.const(0), dyn.const(0))): (q_phi_l, q_phi_r, q_amp_l, q_amp_r) = driving_forces return dyn.Driver( dyn.Q([False, False, True, True, False, False, False]), dyn.Q([ lambda q: q_phi_l(q.phase_left) + phase_force_addition[0](q), lambda q: q_phi_r(q.phase_right) + phase_force_addition[1](q), dyn.const(0), dyn.const(0), dyn.const(0), dyn.const(0), dyn.const(0) ]))
def one_asynchronous_trajectory(friction, driver, omega, dphi, step_number): """ do an asynchronous beat for a while """ dt = 2 * np.pi / omega / 100 initial_condition = dyn.Q([0, dphi, 1, 1, 0, 0, 0]) return dyn.beat_with_forces(initial_condition, driver, dt, step_number, friction_func=friction)
def one_dataset(phase, amplitude): """ obtain velocities for certain phase space point """ initial_condition = dyn.Q( [phase, phase, amplitude, amplitude, 0, 0, 0]) (positions, velocities, _) = dyn.beat_with_forces(initial_condition, driver, dt, 1, friction_func=friction) return (positions.phase_left[0], positions.amplitude_left[0], velocities.phase_left[0], velocities.amplitude_left[0])
def free_driver(driving_forces, friction_func, omega, tau_A, phase_force_addition=(dyn.const(0), dyn.const(0))): """ freely swimming chlamy """ (q_phi_l, q_phi_r, q_amp_l, q_amp_r) = driving_forces return dyn.Driver( dyn.Q([False, False, False, False, False, False, False]), dyn.Q([ lambda q: q_phi_l(q.phase_left) + phase_force_addition[0](q), lambda q: q_phi_r(q.phase_right) + phase_force_addition[1](q), lambda q: dyn.bordered_stiffness( q.phase_left, q.amplitude_left, q_amp_l, friction_func, tau_A, omega), lambda q: dyn.bordered_stiffness( q.phase_right, q.amplitude_right, q_amp_r, friction_func, tau_A, omega), dyn.const(0), dyn.const(0), dyn.const(0) ]))
def clamped_driver(driving_forces, friction_func, omega, tau_A, v_ext=dyn.const(0), phase_force_addition=(dyn.const(0), dyn.const(0))): """ a clamped cell. """ (q_phi_l, q_phi_r, q_amp_l, q_amp_r) = driving_forces return dyn.Driver( dyn.Q([False, False, False, False, True, True, True]), dyn.Q([ lambda q: q_phi_l(q.phase_left) + phase_force_addition[0](q), lambda q: q_phi_r(q.phase_right) + phase_force_addition[1](q), lambda q: dyn.bordered_stiffness( q.phase_left, q.amplitude_left, q_amp_l, friction_func, tau_A, omega), lambda q: dyn.bordered_stiffness( q.phase_right, q.amplitude_right, q_amp_r, friction_func, tau_A, omega), dyn.const(0), v_ext, dyn.const(0) ]))
def forces_from_calibration(friction, omega): """ model calibration for obtaining generalized forces """ time_resolution = 100 frequency = omega / 2 / np.pi dt = (1 / frequency) / time_resolution initial_condition = dyn.Q([0, 0, 1, 1, 0, 0, 0]) (_, _, forces) = dyn.beat_with_forces(initial_condition, calibration_driver(omega), dt, time_resolution, friction_func=friction) return [ dyn.make_phi_func(d) for d in [ forces.phase_left, forces.phase_right, forces.amplitude_left, forces.amplitude_right ] ]
v_ext = -float(sys.argv[1]) # create functions effective_force_{q,a}_{l,r} equilibrium_distance = 0 # (realistic_distance_function, equilibrium_distance) = basal.order_approximation( # second_order=0) distance_function = basal.Deriver(basal.distance_approximation) effective_forces = basal.generate_all_force_functions(distance_function, equilibrium_distance, equilibrium_distance, k_b) friction_func = dyn.include_efficiency_dissipation( dyn.read_friction_matrix()[0]) initial_conditions = dyn.Q([0, dphi, 1, 1, 0, 0, 0]) (q_phi_l, q_phi_r, q_amp_l, q_amp_r) = drivers.forces_from_calibration(friction_func, omega) driver = dyn.Driver( dyn.Q([False, False, False, False, True, True, True]), dyn.Q([ lambda q: q_phi_l(q.phase_left) + effective_forces['p_l'] (q.phase_left + shift, q.amplitude_left, q.phase_right + shift, q. amplitude_right), lambda q: q_phi_r(q.phase_right) + effective_forces['p_r'] (q.phase_left + shift, q.amplitude_left, q.phase_right + shift, q. amplitude_right), lambda q: dyn.bordered_stiffness( q.phase_left, q.amplitude_left, q_amp_l, friction_func, tau_A, omega) + effective_forces['a_l'] (q.phase_left + shift, q.amplitude_left, q.phase_right + shift, q.