def test_serialization(): model, old = ufed_model() pipe = io.StringIO() ufedmm.serialize(old, pipe) pipe.seek(0) new = ufedmm.deserialize(pipe) assert new.__repr__() == old.__repr__() for var1, var2 in zip(old.variables, new.variables): assert var1.__repr__() == var2.__repr__()
dt = 2 * unit.femtoseconds nsteps = 1000000 mass = 30 * unit.dalton * (unit.nanometer / unit.radians)**2 Ks = 1000 * unit.kilojoules_per_mole / unit.radians**2 Ts = 1500 * unit.kelvin limit = 180 * unit.degrees sigma = 18 * unit.degrees height = 2.0 * unit.kilojoules_per_mole deposition_period = 200 phi = ufedmm.CollectiveVariable('phi', model.phi, -limit, limit, mass, Ks, Ts, sigma) psi = ufedmm.CollectiveVariable('psi', model.psi, -limit, limit, mass, Ks, Ts, sigma) ufed = ufedmm.UnifiedFreeEnergyDynamics([phi, psi], temp, height, deposition_period) ufedmm.serialize(ufed, 'ufed_object.yml') integrator = ufedmm.GeodesicBAOABIntegrator(temp, gamma, dt) integrator.setRandomNumberSeed(seed) platform = openmm.Platform.getPlatformByName(args.platform) simulation = ufed.simulation(model.topology, model.system, integrator, platform) ufed.set_positions(simulation, model.positions) ufed.set_random_velocities(simulation, seed) output = ufedmm.MultipleFiles(stdout, 'output.csv') reporter = ufedmm.StateDataReporter(output, 100, ufed.driving_force, step=True, speed=True) simulation.reporters.append(reporter) simulation.step(nsteps)