elif opt == '-t': time_step = float(arg) elif opt == '-T': temperature = float(arg) elif opt == '-v': viscosity = float(arg) if ndim < 1 or ndim > 3: print 'Invalid number of dimensions.' sys.exit(1) # Get a track. small_sphere = Particle(ndim, radius, viscosity, temperature) small_sphere.generate_motion(nsteps, time_step) # Display some results: small_sphere.get_diffusion() print 'Number of dimensions:', ndim print 'Number of steps:', nsteps print 'Radius of particles:', radius, 'um' print 'Viscosity of solution:', viscosity, 'Ps' print 'Temperature of solution:', temperature, 'K' print 'Time step:', time_step, 's' print print 'Theoretical diffusion:', small_sphere.diffusion.theory print 'Diffusion:', small_sphere.diffusion.data print 'Standard error:', small_sphere.diffusion.std_err print 'Absolute error:', small_sphere.diffusion.abs_err print 'Theoretical error:', print small_sphere.diffusion.theory / np.sqrt(nsteps * ndim) * np.sqrt(2) print
flow_coefs[0] = float(arg) elif opt == '-y': flow_coefs[1] = float(arg) elif opt == '-z': flow_coefs[2] = float(arg) if ndim < 1 or ndim > 3: print 'Invalid number of dimensions.' sys.exit(1) # Get a track. small_sphere = Particle(ndim, radius, viscosity, temperature) small_sphere.add_bulk_flow(flow_coefs[:ndim], time_step, nsteps) # The flow is computed in get_diffusion when correcting for it. # No need to call get_bulk_flow. small_sphere.get_diffusion(flow=True) # Display some results: print 'Number of dimensions:', ndim print 'Number of steps:', nsteps print 'Radius of particles:', radius, 'um' print 'Viscosity of solution:', viscosity, 'Ps' print 'Temperature of solution:', temperature, 'K' print 'Time step:', time_step, 's' print print 'Theoretical diffusion:', small_sphere.diffusion.theory print 'Diffusion (flow-corrected):', small_sphere.diffusion.flow_corr print 'Diffusion (uncorrected):', small_sphere.diffusion.data print 'Standard error:', small_sphere.diffusion.std_err print 'Absolute error:', small_sphere.diffusion.abs_err print 'Absolute error from corrected diffusion:',