local_vars = { 'ns0': lambda sdei: sympy.sqrt(sdei.S.d0 * sdei.S.dt * 2.0 / sdei.S.gam1), 'ns1': lambda sdei: sympy.sqrt(sdei.S.d0 * sdei.S.dt * 2.0 / sdei.S.gam2), } const_pars = { 'phi0': lambda sdei: numpy.random.uniform(0.0, 2.0 * numpy.pi, sdei.num_threads) } code = """ dx0 = (is * sinf(x0 - x1) + f1 + amp * cosf(t + phi0)) / gam1; dx1 = (-is * sinf(x0 - x1) + f2) / gam2; """ ns_map = {0: ['ns0', 0], 1: [0, 'ns1']} period_map = {0: sde.PeriodInfo(period=2.0 * math.pi, freq=1.0)} sdei = sde.SDE(code, sim_params, num_vars=2, num_noises=2, noise_map=ns_map, period_map=period_map, local_vars=local_vars, const_pars=const_pars) output = {'path': { 'main': [sde.OutputDecl(func=sde.avg_moments, vars=[0, 1])], }, 'summary': { 'main': [sde.OutputDecl(func=sde.drift_velocity, vars=[0, 1])], } } sdei.prepare(sde.SRK2, init_vector) sdei.simulate(output, block_size=128)
'a2': 'AC drive amplitude for the 2nd particle', 'omega': 'AC drive frequency' } local_vars = { 'ns0': lambda sdei: sympy.sqrt(sdei.S.d0 * sdei.S.dt), } code = """ dx0 = i1 - sinf(x0) + alpha * (i2 - sinf(x1)) + (a1 + alpha * a2) * cosf(omega * t + phi0); dx1 = i2 - sinf(x1) + alpha * (i1 - sinf(x0)) + (alpha * a1 + a2) * cosf(omega * t + phi0); """ ns_map = {0: ['ns0', 0], 1: [0, 'ns0']} period_map = { 0: sde.PeriodInfo(period=2.0 * math.pi, freq=1), 1: sde.PeriodInfo(period=2.0 * math.pi, freq=1) } sdei = sde.SDE(code, sim_params, num_vars=2, num_noises=2, const_pars=const_pars, noise_map=ns_map, period_map=period_map, local_vars=local_vars) output = { 'path': { 'main': [sde.OutputDecl(func=sde.avg_moments, vars=[0, 1])],
'gamma_': 'damping constant', 'psd': 'potential strenght', 'd0': 'noise strength' } local_vars = { 'ns': lambda sdei: sympy.sqrt(sdei.S.d0 * sdei.S.dt * 2.0 * sdei.S.gamma_) } code = """ dx0 = x1; dx1 = -psd * sinf(x0) - gamma_ * x1 + force; """ noise_map = {1: ['ns']} period_map = {0: sde.PeriodInfo(period=2.0 * numpy.pi, freq=1)} sde_ = sde.SDE(code, params, num_vars=2, num_noises=1, noise_map=noise_map, period_map=period_map, local_vars=local_vars) output = { 'summary': { 'main': [sde.OutputDecl(func=sde.diffusion_coefficient, vars=[0])], }, 'path': { 'main': [