def test_total_possible_bonds(self, tmpdir, datadir):
        import epoxpy.abc_type_epoxy_dpd_simulation as es
        import epoxpy.temperature_profile_builder as tpb
        import os

        mix_time = 3e4
        mix_kt = 2.0
        cure_kt = 2.0
        time_scale = 100
        temp_scale = 1
        type_A_md_temp_profile = tpb.LinearTemperatureProfileBuilder(
            initial_temperature=mix_kt, initial_time=mix_time)
        type_A_md_temp_profile.add_state_point(500 * time_scale, cure_kt)

        out_dir = str(tmpdir)
        sim_name = 'shrunk_freud_bonding'
        out_dir = os.path.join(out_dir, sim_name)
        initial_structure_path = os.path.join(datadir, 'shrunk_init.hoomdxml')
        myEpoxySim = es.ABCTypeEpoxyDPDSimulation(
            sim_name,
            mix_time=mix_time,
            mix_kt=mix_kt,
            temp_prof=type_A_md_temp_profile,
            bond=True,
            n_mul=1000.0,
            shrink=True,
            output_dir=out_dir,
            ext_init_struct_path=initial_structure_path,
            reset_random_after_initialize=True)
        possible_bonds = myEpoxySim.total_possible_bonds()
        expected_possible_bonds = 40000  #becuase n_mul is 1000.0 and 10,000 A particles and 20,000 B particles can make a maximum of 40,000 bonds
        assert (possible_bonds == expected_possible_bonds)
        curing_percent = myEpoxySim.get_curing_percentage()
        expected_curing_percent = 0
        assert (curing_percent == expected_curing_percent)
    def test_epoxy_sim_legacy_bonding(self, datadir, tmpdir):
        import epoxpy.abc_type_epoxy_dpd_simulation as es
        import epoxpy.temperature_profile_builder as tpb
        import random
        import os
        import numpy as np
        import gsd.hoomd

        random.seed(1020)

        shrink = False
        legacy_bonding = True
        bonding = True
        exclude_mixing_in_output = False
        mix_time = 3e4
        mix_kt = 2.0
        time_scale = 100
        cure_kt = 2.0
        nmul = 2.0
        log_period = 1e5
        dump_period = 1e2
        curing_log_period = 1e1

        type_A_md_temp_profile = tpb.LinearTemperatureProfileBuilder(
            initial_temperature=mix_kt, initial_time=mix_time)
        type_A_md_temp_profile.add_state_point(500 * time_scale, cure_kt)

        sim_name = 'legacy_bonding'
        out_dir = str(tmpdir)
        out_dir = os.path.join(out_dir, sim_name)
        myEpoxySim = es.ABCTypeEpoxyDPDSimulation(
            sim_name,
            mix_time=mix_time,
            mix_kt=mix_kt,
            temp_prof=type_A_md_temp_profile,
            bond=bonding,
            n_mul=nmul,
            shrink=shrink,
            legacy_bonding=legacy_bonding,
            exclude_mixing_in_output=exclude_mixing_in_output,
            log_curing=False,
            curing_log_period=curing_log_period,
            log_write=log_period,
            dcd_write=dump_period,
            output_dir=out_dir)

        myEpoxySim.execute()

        current_gsd = tmpdir.join(sim_name, 'data.gsd')
        gsd_path = str(current_gsd)
        print('reading gsd: ', gsd_path)
        f = gsd.fl.GSDFile(gsd_path, 'rb')
        t = gsd.hoomd.HOOMDTrajectory(f)
        snapshot = t[-1]
        assert snapshot.particles.N == 100
        current_bonds = snapshot.bonds.N
        print('test_epoxy_sim_legacy_bonding_count. legacy bonds:{}'.format(
            current_bonds))
        assert current_bonds > 30  #Just checking if some bonds are being made
    def test_epoxy_sim_wo_bonding(self, datadir, tmpdir):
        import epoxpy.abc_type_epoxy_dpd_simulation as es
        import epoxpy.temperature_profile_builder as tpb
        import random
        import os
        import numpy as np
        import gsd.hoomd

        random.seed(1020)
        print('\n# Test: test_epoxy_sim_wo_bonding')

        mix_time = 3e4
        mix_kt = 2.0
        cure_kt = 2.0
        time_scale = 100
        temp_scale = 1
        type_A_md_temp_profile = tpb.LinearTemperatureProfileBuilder(
            initial_temperature=mix_kt, initial_time=mix_time)
        type_A_md_temp_profile.add_state_point(500 * time_scale, cure_kt)

        sim_name = 'wo_bonding'
        out_dir = str(tmpdir)
        exclude_mixing_in_output = False
        out_dir = os.path.join(out_dir, sim_name)
        myEpoxySim = es.ABCTypeEpoxyDPDSimulation(
            sim_name,
            mix_time=mix_time,
            mix_kt=mix_kt,
            temp_prof=type_A_md_temp_profile,
            output_dir=out_dir,
            n_mul=2.0,
            exclude_mixing_in_output=exclude_mixing_in_output,
            shrink=False)

        myEpoxySim.execute()

        total_time = type_A_md_temp_profile.get_total_sim_time()
        md_time = total_time - mix_time
        gsd_write_period = myEpoxySim.dcd_write
        total_frames = int(round(total_time / gsd_write_period))
        total_md_frames = int(round(md_time / gsd_write_period))
        print('total_frames:{}, md frames:{}'.format(total_frames,
                                                     total_md_frames))

        print('current directory: {}'.format(os.getcwd()))
        print('tmp dir: {}'.format(tmpdir))
        print('datadir: {}'.format(datadir))

        current_gsd = tmpdir.join(sim_name, 'data.gsd')
        gsd_path = str(current_gsd)
        f = gsd.fl.GSDFile(gsd_path, 'rb')
        t = gsd.hoomd.HOOMDTrajectory(f)
        snapshot = t[-1]

        assert snapshot.particles.N == 100
Exemple #4
0
import epoxpy.temperature_profile_builder as tpb
import epoxpy.bonding as bondClass
import random
import os
import gsd.hoomd
import numpy as np
import epoxpy.common as cmn

random.seed(1020)

mix_time = 1e3
mix_kt = 2.0
cure_kt = 2.0
time_scale = 100
temp_scale = 1
type_A_md_temp_profile = tpb.LinearTemperatureProfileBuilder(
    initial_temperature=mix_kt, initial_time=mix_time)
type_A_md_temp_profile.add_state_point(500 * time_scale, cure_kt)

out_dir = str('.')
sim_name = 'shrunk_freud_bonding'
out_dir = os.path.join(out_dir, sim_name)
myEpoxySim = es.ABCTypeEpoxyLJHarmonicSimulation(
    sim_name,
    mix_time=mix_time,
    mix_kt=mix_kt,
    temp_prof=type_A_md_temp_profile,
    bond=True,
    n_mul=4.0,
    shrink=True,
    shrink_time=1e4,
    mix_dt=1e-4,
Exemple #5
0
av_calibrationT = 439.3636  #K
av_aij_DDS_DEGBA = 30.729
av_aij_DDS_PES = 25.003
av_aij_DEGBA_PES = 30.532

temperature_profile = 'iso'  #'lin_ramp''step'
bonding_period = 10
percent_bonds_per_step = 0.005
kT = 500 / av_calibrationT
AB_bond_const = 4.0
AB_bond_dist = 0.0
CC_bond_const = 4.0
CC_bond_dist = 0.0

if temperature_profile is 'iso':
    temp_profile = tpb.LinearTemperatureProfileBuilder(
        initial_temperature=kT, initial_time=mixing_time)
    temp_profile.add_state_point(t_Final, kT)
elif temperature_profile is 'lin_ramp':
    temp_profile = tpb.LinearTemperatureProfileBuilder(
        initial_temperature=300 / calibrationT, initial_time=mixing_time)
    temp_profile.add_state_point(t_Final, kT)
elif temperature_profile is 'step':
    temp_profile = tpb.LinearTemperatureProfileBuilder(
        initial_temperature=300 / calibrationT, initial_time=mixing_time)
    temp_profile.add_state_point(t_SetT, kT)
    temp_profile.add_state_point(t_Final * time_scale, kT)
output_dir = os.path.join('.', temperature_profile)
myEpoxySim = es.ABCTypeEpoxySimulation(
    temperature_profile,
    output_dir=output_dir,
    mix_time=mixing_time,
    def test_epoxy_sim_dybond_lj_harmonic_langevin(self, datadir, tmpdir):
        """
        Here we are doing regression testing for the new bonding routine that operates and the mbuild initial structure
        whose volume is shrunk to a density of 1.0
        :param datadir:
        :param tmpdir:
        :return:
        """
        import epoxpy.abc_type_epoxy_lj_harmonic_simulation as es
        import epoxpy.temperature_profile_builder as tpb
        import epoxpy.bonding as bondClass
        import random
        import os
        import gsd.hoomd
        import numpy as np
        import epoxpy.common as cmn

        random.seed(1020)

        mix_time = 1e3
        mix_kt = 2.0
        cure_kt = 2.0
        time_scale = 100
        temp_scale = 1
        type_A_md_temp_profile = tpb.LinearTemperatureProfileBuilder(
            initial_temperature=mix_kt, initial_time=mix_time)
        type_A_md_temp_profile.add_state_point(500 * time_scale, cure_kt)

        out_dir = str(tmpdir)
        sim_name = 'shrunk_freud_bonding'
        out_dir = os.path.join(out_dir, sim_name)
        myEpoxySim = es.ABCTypeEpoxyLJHarmonicSimulation(
            sim_name,
            mix_time=mix_time,
            mix_kt=mix_kt,
            temp_prof=type_A_md_temp_profile,
            bond=True,
            n_mul=6.0,
            shrink=True,
            shrink_time=1e5,
            mix_dt=1e-4,
            md_dt=1e-2,
            integrator=cmn.Integrators.LANGEVIN.name,
            output_dir=out_dir,
            use_dybond_plugin=True)

        myEpoxySim.execute()

        current_gsd = tmpdir.join(sim_name, 'data.gsd')
        gsd_path = str(current_gsd)
        print('reading gsd: ', gsd_path)
        f = gsd.fl.GSDFile(gsd_path, 'rb')
        t = gsd.hoomd.HOOMDTrajectory(f)
        snapshot = t[-1]
        current_bonds = snapshot.bonds.N
        assert snapshot.particles.N == 300
        print('test_epoxy_sim_freud_shrunk_regression. current:{}'.format(
            current_bonds))
        assert current_bonds > 30  #Just checking if some bonds are being made

        idxs, counts = np.unique(snapshot.bonds.group, return_counts=True)
        print('########################idxs', idxs, counts)
        print(snapshot.bonds.group)
        for index, idx in enumerate(idxs):
            p_typeid = snapshot.particles.typeid[idx]
            p_type = snapshot.particles.types[p_typeid]
            if p_type == 'A':
                assert (counts[index] <= bondClass.FreudBonding.MAX_A_BONDS)
            elif p_type == 'B':
                assert (counts[index] <= bondClass.FreudBonding.MAX_B_BONDS)