torsion_force_constants=torsion_force_constants, equil_bond_angles=equil_bond_angles, equil_torsion_angles=equil_torsion_angles, torsion_periodicities=torsion_periodicities, include_nonbonded_forces=include_nonbonded_forces, include_bond_forces=include_bond_forces, include_bond_angle_forces=include_bond_angle_forces, include_torsion_forces=include_torsion_forces, constrain_bonds=constrain_bonds, sequence=sequence, positions=positions, monomer_types=[A], ) # store the cg model so that we can do various analyses. cgmodel.export("stored_cgmodel.pkl") if not os.path.exists(output_data) or overwrite_files == True: run_replica_exchange( cgmodel.topology, cgmodel.system, cgmodel.positions, temperature_list=temperature_list, simulation_time_step=simulation_time_step, total_simulation_time=total_simulation_time, exchange_frequency=exchange_frequency, output_data=output_data, ) else: print("Replica output files exist")
def signac_run_replica_exchange(job): # Run replica exchange simulation for current job parameters # Job settings output_directory = os.path.join(job.workspace(), "output") if not os.path.exists(output_directory): os.mkdir(output_directory) overwrite_files = True # overwrite files. # Replica exchange simulation settings total_simulation_time = 0.05 * unit.nanosecond simulation_time_step = 10.0 * unit.femtosecond total_steps = int(np.floor(total_simulation_time / simulation_time_step)) output_data = os.path.join(output_directory, "output.nc") number_replicas = 36 min_temp = 100.0 * unit.kelvin max_temp = 500.0 * unit.kelvin temperature_list = get_temperature_list(min_temp, max_temp, number_replicas) exchange_frequency = 100 # Number of steps between exchange attempts collision_frequency = 5 / unit.picosecond include_bond_forces = True include_bond_angle_forces = True include_nonbonded_forces = True include_torsion_forces = True constrain_bonds = False mass = 100.0 * unit.amu # mass and charge are defaults. bb = { "particle_type_name": "bb", "sigma": job.sp.sigma_bb * unit.nanometer, "epsilon": job.sp.epsilon_bb * unit.kilojoules_per_mole, "mass": mass } sc = { "particle_type_name": "sc", "sigma": job.sp.sigma_sc * unit.nanometer, "epsilon": job.sp.epsilon_sc * unit.kilojoules_per_mole, "mass": mass } # Monomer definition A = { "monomer_name": "A", "particle_sequence": [bb, sc], "bond_list": [[0, 1]], "start": 0, "end": 0, } sequence = 24 * [A] # Bond definitions bond_lengths = { "default_bond_length": job.sp.equil_bond_length * unit.nanometer } bond_force_constants = { "default_bond_force_constant": job.sp.k_bond * unit.kilojoule_per_mole / unit.nanometer / unit.nanometer } # Bond angle definitions bond_angle_force_constants = { "default_bond_angle_force_constant": job.sp.k_angle * unit.kilojoule_per_mole / unit.radian / unit.radian } equil_bond_angles = { "default_equil_bond_angle": job.sp.equil_bond_angle * unit.degrees } # torsion angle definitions torsion_force_constants = { "default_torsion_force_constant": 0.0 * unit.kilojoule_per_mole, "bb_bb_bb_bb_torsion_force_constant": job.sp.k_torsion * unit.kilojoule_per_mole } torsion_phase_angles = { "sc_bb_bb_sc_torsion_phase_angle": 0 * unit.degrees, "bb_bb_bb_bb_torsion_phase_angle": job.sp.torsion_phase_angle * unit.degrees, "bb_bb_bb_sc_torsion_phase_angle": 0 * unit.degrees, } torsion_periodicities = { "sc_bb_bb_sc_torsion_periodicity": job.sp.torsion_periodicity, "bb_bb_bb_bb_torsion_periodicity": job.sp.torsion_periodicity, "bb_bb_bb_sc_torsion_periodicity": job.sp.torsion_periodicity, } # Get initial positions from local file pdb_path = os.path.join(proj_directory, "24mer_1b1s_initial_structure.pdb") positions = PDBFile(pdb_path).getPositions() # Build a coarse grained model cgmodel = CGModel( particle_type_list=[bb, sc], bond_lengths=bond_lengths, bond_force_constants=bond_force_constants, bond_angle_force_constants=bond_angle_force_constants, torsion_force_constants=torsion_force_constants, equil_bond_angles=equil_bond_angles, torsion_phase_angles=torsion_phase_angles, torsion_periodicities=torsion_periodicities, include_nonbonded_forces=include_nonbonded_forces, include_bond_forces=include_bond_forces, include_bond_angle_forces=include_bond_angle_forces, include_torsion_forces=include_torsion_forces, constrain_bonds=constrain_bonds, sequence=sequence, positions=positions, monomer_types=[A], ) # store the cg model so that we can do various analyses. cgmodel.export(job.fn("stored_cgmodel.pkl")) if not os.path.exists(output_data) or overwrite_files == True: run_replica_exchange( cgmodel.topology, cgmodel.system, cgmodel.positions, friction=collision_frequency, temperature_list=temperature_list, simulation_time_step=simulation_time_step, total_simulation_time=total_simulation_time, exchange_frequency=exchange_frequency, output_data=output_data, ) else: print("Replica output files exist")
def signac_run_CEI_replica_exchange(job): # Run replica exchange simulation for current job parameters print(f'job_parameters:') print(job.sp) rep_exch_begin = time.perf_counter() # Job settings output_directory = os.path.join(job.workspace(),"output_CEI") if not os.path.exists(output_directory): os.mkdir(output_directory) overwrite_files = True # overwrite files. global_context_cache.platform = openmm.Platform.getPlatformByName("CUDA") # Replica exchange simulation settings total_simulation_time = 200.0 * unit.nanosecond simulation_time_step = 5.0 * unit.femtosecond total_steps = int(np.floor(total_simulation_time / simulation_time_step)) output_data = os.path.join(output_directory, "output.nc") number_replicas = job.sp.n_replica min_temp = 200.0 * unit.kelvin max_temp = 600.0 * unit.kelvin # Load in CEI temperature list: temperature_list = pickle.load(open(job.fn("opt_T_spacing.pkl"),"rb")) exchange_frequency = job.sp.exch_freq # Number of steps between exchange attempts collision_frequency = job.sp.coll_freq/unit.picosecond include_bond_forces = True include_bond_angle_forces = True include_nonbonded_forces = True include_torsion_forces = True constrain_bonds = False mass = 100.0 * unit.amu # mass and charge are defaults. bb = { "particle_type_name": "bb", "sigma": job.sp.sigma_bb * unit.angstrom, "epsilon": job.sp.epsilon_bb * unit.kilojoules_per_mole, "mass": mass } sc = { "particle_type_name": "sc", "sigma": job.sp.sigma_sc * unit.angstrom, "epsilon": job.sp.epsilon_sc * unit.kilojoules_per_mole, "mass": mass } # Monomer definition A = { "monomer_name": "A", "particle_sequence": [bb, sc], "bond_list": [[0, 1]], "start": 0, "end": 0, } sequence = 24 * [A] # Bond definitions bond_lengths = {"default_bond_length": job.sp.equil_bond_length * unit.nanometer} bond_force_constants = { "default_bond_force_constant": job.sp.k_bond * unit.kilojoule_per_mole / unit.nanometer / unit.nanometer } # Bond angle definitions bond_angle_force_constants = { "default_bond_angle_force_constant": job.sp.k_angle * unit.kilojoule_per_mole / unit.radian / unit.radian } equil_bond_angles = { "default_equil_bond_angle": job.sp.equil_bond_angle_bb_bb_sc * unit.degrees, "bb_bb_bb_equil_bond_angle": job.sp.equil_bond_angle_bb_bb_bb * unit.degrees} # torsion angle definitions torsion_force_constants = { "default_torsion_force_constant": 0.0 * unit.kilojoule_per_mole, "bb_bb_bb_bb_torsion_force_constant": job.sp.k_torsion * unit.kilojoule_per_mole} # Need to substract 180 degrees from specified torsion for mdtraj consistency torsion_phase_angles = { "sc_bb_bb_sc_torsion_phase_angle": 0 * unit.degrees, "bb_bb_bb_bb_torsion_phase_angle": (job.sp.equil_torsion_angle_bb_bb_bb_bb-180) * unit.degrees, "bb_bb_bb_sc_torsion_phase_angle": 0 * unit.degrees, } torsion_periodicities = { "sc_bb_bb_sc_torsion_periodicity": job.sp.torsion_periodicity, "bb_bb_bb_bb_torsion_periodicity": job.sp.torsion_periodicity, "bb_bb_bb_sc_torsion_periodicity": job.sp.torsion_periodicity, } # Get initial positions from local file pdb_path = os.path.join(proj_directory, f"initial_structure_trial_{job.sp.trial}.pdb") positions = PDBFile(pdb_path).getPositions() # Build a coarse grained model cgmodel = CGModel( particle_type_list=[bb, sc], bond_lengths=bond_lengths, bond_force_constants=bond_force_constants, bond_angle_force_constants=bond_angle_force_constants, torsion_force_constants=torsion_force_constants, equil_bond_angles=equil_bond_angles, torsion_phase_angles=torsion_phase_angles, torsion_periodicities=torsion_periodicities, include_nonbonded_forces=include_nonbonded_forces, include_bond_forces=include_bond_forces, include_bond_angle_forces=include_bond_angle_forces, include_torsion_forces=include_torsion_forces, constrain_bonds=constrain_bonds, positions=positions, sequence=sequence, monomer_types=[A], ) # store the cg model so that we can do various analyses. cgmodel.export(job.fn("stored_cgmodel.pkl")) if not os.path.exists(output_data) or overwrite_files == True: run_replica_exchange( cgmodel.topology, cgmodel.system, cgmodel.positions, friction=collision_frequency, temperature_list=temperature_list, simulation_time_step=simulation_time_step, total_simulation_time=total_simulation_time, exchange_frequency=exchange_frequency, output_data=output_data, ) else: print("Replica output files exist") rep_exch_end = time.perf_counter() print(f'replica exchange run time: {rep_exch_end-rep_exch_begin}')