def run_exit_times(statePair, runs): np.random.seed() asympot = potentials.asym3Dpotential(scalefactor=2.0) r1 = np.array(np.zeros(3)) p1 = mrd.particle(r1, 1.0) sphereboundary = mrd.reflectiveSphere(4.) integrator = integrators.brownianDynamicsSp(asympot, sphereboundary, p1, 0.001, 1.0) sim = mrd.simulation(integrator) exitTimes = [] exitPositions = [] fpts = [] exits = 0 run = 0 totalRuns = 0 while run < runs: integrator.pa.position = np.array(minima[statePair[0]]) integrator.clock = 0. totalRuns += 1 while True: sim.integrator.integrate() if np.linalg.norm(minima[statePair[1]] - integrator.pa.position) < 0.2: fpts.append(integrator.clock) run += 1 break elif np.linalg.norm(integrator.pa.position) > R: exits += 1 exitTimes.append(integrator.clock) exitPositions.append(integrator.pa.position) break print str(statePair[0]) + ' to ' + str(statePair[1]) return [np.array(fpts), totalRuns, exitTimes, exitPositions]
def run_mfpts_to_bath(state, runs, scalef, dt, runbound): global MFPTS, minima np.random.seed() asympot3D = potentials.asym3Dpotential(scalefactor = scalef) p1 = mrd.particle(np.zeros(3), 1.0) sphereboundary = mrd.reflectiveSphere(4.0) integrator = integrators.brownianDynamicsSp(asympot3D, sphereboundary, p1, dt, 1.0) sim = mrd.simulation(integrator) fpts = [] for run in range(runs): integrator.pa.position = np.array(minima[state]) fpts.append(sim.run_mfpt(runbound)) print 'state '+str(state)+' done' return np.array(fpts)
def run_mfpts_from_bath(bathRad, numpoints, scalefactor, dt): np.random.seed() asympot3D = potentials.asym3Dpotential(scalefactor=scalefactor) p1 = mrd.particle(np.zeros(3), 1.0) sphereboundary = mrd.reflectiveSphere(bathRad) integrator = integrators.brownianDynamicsSp(asympot3D, sphereboundary, p1, dt, 1.0) sim = mrd.simulation(integrator) startpoints = get_startpoints(numpoints, bathRad - radiusThreshold) fpts = [] for startpoint in startpoints: integrator.pa.position = startpoint integrator.clock = 0. fpts.append(sim.run_mfpt_points(np.array(minima), 0.2)) print 'bath to ' + str(bathRad) return np.array(fpts)
def run_mfpts_from_bath(startPosition, bathRad, dt): np.random.seed() p1 = mrd.particle(np.zeros(3), D_CO) msm = mrd.MSM(T, minima) msm.exitStates = [] boundary = mrd.reflectiveSphere(bathRad) integrator = integrators.MSMRDtruncTrajs3D(msm, bathRad, p1, dt, interactionRadius, boundary, model) sim = mrd.simulation(integrator) integrator.particle.position = startPosition integrator.clock = 0. integrator.transition = False integrator.MSM.state = -1 integrator.MSMactive = False integrator.MSM.exit = False return sim.run_mfpt_state(boundState)
def run_mfpts_to_bath(state, runs, dt = 0.1): p1 = mrd.particle(np.zeros(3), D_CO) msm = mrd.MSM(T, minima) msm.exitStates = [] boundary = mrd.reflectiveSphere(2.*interactionRadius) integrator = integrators.MSMRDtruncTrajs3D(msm, 2.*interactionRadius, p1, dt, interactionRadius, boundary, model) sim = mrd.simulation(integrator) fpts = [] for run in range(runs): integrator.particle.position = np.zeros(3) integrator.clock = 0. integrator.MSM.state = state integrator.lastState = state integrator.lastStateTime = 0 integrator.transition = True integrator.MSMactive = True integrator.MSM.exit = False fpts.append(sim.run_mfpt(40.)) print str(state)+' to bath' return np.array(fpts)
def run_mfpts_to_bath(state, runs, dt=0.001): p1 = mrd.particle(np.zeros(2), 1.0) msm = mrd.MSM(T, minima) msm.exitStates = [] boundary = mrd.reflectiveSphere(4.) integrator = integrators.MSMRDtruncTrajs(msm, 4.0, p1, 0.001, model, 2.5) sim = mrd.simulation(integrator) fpts = [] for run in range(runs): integrator.p.position = np.zeros(2) integrator.clock = 0. integrator.MSM.state = state integrator.lastState = state integrator.lastStateTime = 0 integrator.transition = True integrator.MSMactive = True integrator.MSM.exit = False fpts.append(sim.run_mfpt(2.7)) print str(state) + ' to bath' return np.array(fpts)
def run_mfpts_from_bath(bathRad, numpoints, dt): np.random.seed() p1 = mrd.particle(np.zeros(2), 1.0) msm = mrd.MSM(T, minima) msm.exitStates = [] boundary = mrd.reflectiveSphere(bathRad) integrator = integrators.MSMRDtruncTrajs(msm, bathRad, p1, 0.001, model, 2.5) sim = mrd.simulation(integrator) fpts = [] startpoints = get_startpoints(numpoints, bathRad - radiusThreshold) for startpoint in startpoints: integrator.p.position = startpoint integrator.clock = 0. integrator.transition = False integrator.MSM.state = -1 integrator.MSMactive = False integrator.MSM.exit = False fpts.append(sim.run_mfpt_states()) print 'bath to ' + str(bathRad) return np.array(fpts)
def run_exit_times(statePair, runs): np.random.seed() r1 = np.array(np.zeros(3)) p1 = mrd.particle(r1, 1.0) msm = mrd.MSM(T, minima) msm.exitStates = [] boundary = mrd.reflectiveSphere(4.) integrator = integrators.MSMRDtruncTrajs3D(msm, 4.0, p1, 0.001, 2.5, boundary, model) sim = mrd.simulation(integrator) exitTimes = [] exitPositions = [] fpts = [] exits = 0 run = 0 totalRuns = 0 while run < runs: integrator.particle.position = np.array(np.zeros(3)) integrator.clock = 0. integrator.MSM.state = statePair[0] integrator.lastState = statePair[0] integrator.transition = True integrator.MSMactive = True totalRuns += 1 while True: sim.integrator.integrate() if integrator.MSM.state == statePair[1]: fpts.append(integrator.clock) run += 1 break elif not integrator.MSMactive: exits += 1 exitTimes.append(integrator.clock) exitPositions.append(integrator.particle.position) break print str(statePair[0])+' to ' + str(statePair[1]) return [np.array(fpts), totalRuns, exitTimes, exitPositions]