Ejemplo n.º 1
0
        dcd = app.DCDFile(file=dcdfile, topology=topology, dt=timestep)

    # The actual simulation
    k = 0
    for iteration in range(args.iterations):
        # Propagate configurations and salt concentrations
        t0 = time()
        langevin.step(args.steps)
        if not args.fix_salt:
            salinator.update(nattempts=1)
        iter_time = time() - t0
        if iteration % args.save_freq == 0:
            # Record the simulation data
            Record.record_netcdf(ncfile,
                                 context,
                                 salinator.swapper,
                                 k,
                                 attempt=0,
                                 sync=False)
            ncfile.groups['Sample state data']['time'][k] = iter_time
            ncfile.sync()
            if args.save_configs:
                # Record the simulation configurations
                state = context.getState(getPositions=True,
                                         enforcePeriodicBox=True)
                positions = state.getPositions(asNumpy=True)
                box_vectors = state.getPeriodicBoxVectors()
                dcd.writeModel(positions=positions,
                               periodicBoxVectors=box_vectors)
            k += 1
Ejemplo n.º 2
0
        # Update SAMS estimator
        nwater, ncation, nanion = mcdriver.get_identity_counts()
        noisy = np.zeros(args.saltmax + 1)
        noisy[ncation] = 1
        state_counts[ncation] += 1
        bias = adaptor.update(state=ncation,
                              noisy_observation=noisy,
                              histogram=state_counts)

        # Save data
        if iteration % args.save_freq == 0:
            # Record the simulation data
            Record.record_netcdf(ncfile,
                                 context,
                                 mcdriver,
                                 k,
                                 attempt=0,
                                 sync=False)
            ncfile.groups['Sample state data']['sams bias'][k, :] = bias
            ncfile.sync()
            if args.save_configs:
                # Record the simulation configurations
                state = context.getState(getPositions=True,
                                         enforcePeriodicBox=True)
                positions = state.getPositions(asNumpy=True)
                box_vectors = state.getPeriodicBoxVectors()
                dcd.writeModel(positions=positions,
                               periodicBoxVectors=box_vectors)
            k += 1
Ejemplo n.º 3
0
        dcdfile = open(args.out + '.dcd', 'wb')
        dcd = app.DCDFile(file=dcdfile, topology=wbox.topology, dt=timestep)

    # The actual simulation
    k = 0
    for iteration in range(args.iterations):
        # Propagate configurations and salt concentrations, and update SAMS bias.
        langevin.step(args.steps)
        sams_salinator.update()

        # Save data
        if iteration % args.save_freq == 0:
            # Record the simulation data
            Record.record_netcdf(ncfile,
                                 context,
                                 sams_salinator.swapper,
                                 k,
                                 attempt=0,
                                 sams_bias=sams_salinator.bias,
                                 sync=True)

            if args.save_configs:
                # Record the simulation configurations
                state = context.getState(getPositions=True,
                                         enforcePeriodicBox=True)
                positions = state.getPositions(asNumpy=True)
                box_vectors = state.getPeriodicBoxVectors()
                dcd.writeModel(positions=positions,
                               periodicBoxVectors=box_vectors)
            k += 1