def run_simulation(request):
    _voronoi = request.param["voronoi"]
    _hop_range_value = request.param["hop_range"]
    _transiting = request.param["transiting"]
    _koopmans = request.param["koopmans"]
    if _hop_range_value != 10.0:
        _hop_range = True
    else:
        _hop_range = False
    _modifiers = {"True": [], "False": []}
    for _key in request.param.keys():
        _boolean = eval("".join(["_", _key]))
        _modifiers[repr(_boolean)].append(_key)

    # ---==============================================---
    # ---======== Directory and File Structure ========---
    # ---==============================================---

    input_morph_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_morph_dir = os.path.join(TEST_ROOT, "output_OC")
    output_orca_dir = None
    input_device_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_device_dir = os.path.join(TEST_ROOT, "output_OC")

    # ---==============================================---
    # ---========== Input Morphology Details ==========---
    # ---==============================================---

    morphology = "donor_polymer.xml"
    input_sigma = 3.0
    device_morphology = None
    device_components = {}
    overwrite_current_data = True
    random_seed_override = 929292929

    # ---==============================================---
    # ---============= Execution Modules ==============---
    # ---==============================================---

    execute_fine_graining = False  # Requires: None
    execute_molecular_dynamics = False  # Requires: fine_graining
    execute_obtain_chromophores = (
        True)  # Requires: Atomistic morphology, or molecular_dynamics
    execute_ZINDO = False  # Requires: obtain_chromophores
    execute_calculate_transfer_integrals = False  # Requires: execute_ZINDO
    execute_calculate_mobility = False  # Requires: calculate_transfer_integrals
    execute_device_simulation = (
        False
    )  # Requires: calculate_transfer_integrals for all device_components

    # ---==============================================---
    # ---============ Chromophore Parameters ==========---
    # ---==============================================---

    molecule_terminating_connections = {"C1": [[2, 1]], "C10": [[2, 1]]}
    AA_rigid_body_species = {}
    CG_site_species = {"A": "donor", "B": "none", "C": "none"}
    use_voronoi_neighbours = _voronoi
    maximum_hole_hop_distance = _hop_range
    maximum_electron_hop_distance = _hop_range
    permit_hops_through_opposing_chromophores = _transiting
    remove_orca_inputs = False
    remove_orca_outputs = True
    chromophore_length = 3

    # ---==============================================---
    # ---=== Chromophore Energy Scaling Parameters ====---
    # ---==============================================---

    chromophore_species = {
        "donor": {
            "literature_MO": -5.0,
            "target_DOS_std": 0.1,
            "reorganisation_energy": 0.3064,
            "species": "donor",
            "VRH_delocalisation": 2e-10,
        }
    }
    use_koopmans_approximation = _koopmans
    koopmans_hopping_prefactor = 1E-3

    # ---==============================================---
    # ---================= Begin run ==================---
    # ---==============================================---

    parameter_file = os.path.realpath(__file__)
    proc_IDs = hf.get_CPU_cores()
    parameter_names = [
        i for i in dir() if (not i.startswith("_")) and (
            not i.startswith("@")) and (not i.startswith("Test")) and (
                not i.startswith("test")) and (i not in [
                    "run_MorphCT",
                    "helper_functions",
                    "hf",
                    "os",
                    "shutil",
                    "TestCommand",
                    "TEST_ROOT",
                    "setup_module",
                    "teardown_module",
                    "testing_tools",
                    "sys",
                    "pytest",
                    "request",
                ])
    ]
    parameters = {}
    for name in parameter_names:
        parameters[name] = locals()[name]

    # ---==============================================---
    # ---=============== Setup Prereqs ================---
    # ---==============================================---

    try:
        shutil.rmtree(output_morph_dir)
    except OSError:
        pass
    os.makedirs(
        os.path.join(output_morph_dir,
                     os.path.splitext(morphology)[0], "code"))
    shutil.copy(
        os.path.join(
            TEST_ROOT,
            "assets",
            os.path.splitext(morphology)[0],
            "OC",
            morphology.replace(".xml", "_post_run_HOOMD.pickle"),
        ),
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ),
    )

    run_MorphCT.simulation(
        **parameters)  # Execute MorphCT using these simulation parameters
    # The output dictionary from this fixing
    fix_dict = {}
    # Load the output pickle
    output_pickle_data = hf.load_pickle(
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ))
    fix_dict["output_AA_morphology_dict"] = output_pickle_data[0]
    fix_dict["output_CG_morphology_dict"] = output_pickle_data[1]
    fix_dict["output_CG_to_AAID_master"] = output_pickle_data[2]
    fix_dict["output_parameter_dict"] = output_pickle_data[3]
    fix_dict["output_chromophore_list"] = output_pickle_data[4]
    # Load the correct expected pickle
    pickle_name = os.path.join(
        input_morph_dir, "OC",
        morphology.replace(".xml", "_post_obtain_chromophores"))
    pickle_name_modified = "_".join([pickle_name] + sorted(_modifiers["True"]))
    expected_pickle_data = hf.load_pickle("".join(
        [pickle_name_modified, ".pickle"]))
    fix_dict["expected_AA_morphology_dict"] = expected_pickle_data[0]
    fix_dict["expected_CG_morphology_dict"] = expected_pickle_data[1]
    fix_dict["expected_CG_to_AAID_master"] = expected_pickle_data[2]
    fix_dict["expected_parameter_dict"] = expected_pickle_data[3]
    fix_dict["expected_chromophore_list"] = expected_pickle_data[4]
    return fix_dict
예제 #2
0
def run_simulation(request):
    _voltage = request.param["voltage"]
    _no_dark = request.param["no_dark"]
    _no_coulomb = request.param["no_coulomb"]
    _stdout_log = request.param["stdout_log"]
    # ---==============================================---
    # ---======== Directory and File Structure ========---
    # ---==============================================---

    input_morph_dir = os.path.join(TEST_ROOT, "output_DBL", "morph_inputs")
    output_morph_dir = os.path.join(TEST_ROOT, "output_DBL", "morph_outputs")
    output_orca_dir = None
    input_device_dir = os.path.join(TEST_ROOT, "output_DBL", "device_inputs")
    output_device_dir = os.path.join(TEST_ROOT, "output_DBL", "device_outputs")

    # ---==============================================---
    # ---========== Input Morphology Details ==========---
    # ---==============================================---

    morphology = None
    input_sigma = 1.0
    device_morphology = "bilayer"
    device_components = {
        0: "donor_crystal",
        1: "acceptor_crystal",
        2: "mixed_crystal_bilayer",
    }
    overwrite_current_data = True
    random_seed_override = 929292929

    # ---==============================================---
    # ---============= Execution Modules ==============---
    # ---==============================================---

    execute_fine_graining = False  # Requires: None
    execute_molecular_dynamics = False  # Requires: fine_graining
    execute_obtain_chromophores = (
        False)  # Requires: Atomistic morphology, or molecular_dynamics
    execute_ZINDO = False  # Requires: obtain_chromophores
    execute_calculate_transfer_integrals = False  # Requires: execute_ZINDO
    execute_calculate_mobility = False  # Requires: calculate_transfer_integrals
    execute_device_simulation = (
        True
    )  # Requires: calculate_transfer_integrals for all device_components

    # ---==============================================---
    # ---=== General Kinetic Monte Carlo Parameters ===---
    # ---==============================================---

    # ---=== Universal KMC Parameters ===---
    system_temperature = 290
    use_simple_energetic_penalty = False
    record_carrier_history = True
    use_VRH = True

    # ---=== Device Specific KMC Parameters ===---
    # Material parameters
    absorption_coefficient = 1.3E4
    relative_permittivity = 3
    donor_HOMO = -5.3
    acceptor_LUMO = -3.9
    cathode_work_function = -4.2
    anode_work_function = -5.0
    recombination_rate = 1E9
    coulomb_capture_radius = 1E-9
    wrap_device_xy = False
    exciton_lifetime = 0.5E-9
    forster_radius = 4.3E-9
    hopping_prefactor = 1E-4
    MA_prefactor = 1E11
    MA_localisation_radius = 1E-9

    # External parameters
    incident_flux = 100
    incident_wavelength = 500E-9

    # Simulation
    voltage_sweep = _voltage
    morphology_cell_size = 1E-8
    minimum_number_of_photoinjections = 10
    fastest_event_allowed = 1E-18
    slowest_event_allowed = 1E-8
    disable_dark_injection = _no_dark
    disable_coulombic = _no_coulomb
    output_log_to_stdout = _stdout_log

    # ---==============================================---
    # ---================= Begin run ==================---
    # ---==============================================---

    parameter_file = os.path.realpath(__file__)
    # Force serial running
    proc_IDs = [0]
    parameter_names = [
        i for i in dir() if (not i.startswith("_")) and (
            not i.startswith("@")) and (not i.startswith("Test")) and (
                not i.startswith("test")) and (i not in [
                    "run_MorphCT",
                    "helper_functions",
                    "hf",
                    "os",
                    "shutil",
                    "TestCommand",
                    "TEST_ROOT",
                    "setup_module",
                    "teardown_module",
                    "testing_tools",
                    "sys",
                    "pytest",
                    "pickle",
                    "request",
                ])
    ]
    parameters = {}
    for name in parameter_names:
        parameters[name] = locals()[name]

    # ---==============================================---
    # ---=============== Setup Prereqs ================---
    # ---==============================================---

    try:
        shutil.rmtree(os.path.join(TEST_ROOT, "output_DBL"))
    except OSError:
        pass

    shutil.copytree(
        os.path.join(TEST_ROOT, "assets", "device_bilayer"),
        os.path.join(TEST_ROOT, "output_DBL"),
    )

    run_MorphCT.simulation(
        **parameters)  # Execute MorphCT using these simulation parameters
    return voltage_sweep
예제 #3
0
"""
Boolean that can be used to toggle Coulombic interactions between carriers in the device at the same time
"""
disable_coulombic = True
"""
Divert log output to the terminal rather than the KMC_log files (useful for testing or when running only one voltage
on a single core)
"""
output_log_to_stdout = True

# ---==============================================---
# ---================= Begin run ==================---
# ---==============================================---

if __name__ == "__main__":
    from morphct import run_MorphCT
    from morphct.code import helper_functions as hf

    parameter_file = __os.path.realpath(__file__)
    proc_IDs = hf.get_CPU_cores()
    parameter_names = [
        i for i in dir()
        if (not i.startswith("__")) and (not i.startswith("@")) and (
            i not in ["run_MorphCT", "helper_functions", "hf"])
    ]
    parameters = {}
    for name in parameter_names:
        parameters[name] = locals()[name]
    run_MorphCT.simulation(
        **parameters)  # Execute MorphCT using these simulation parameters
def run_simulation():
    # ---==============================================---
    # ---======== Directory and File Structure ========---
    # ---==============================================---

    input_morph_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_morph_dir = os.path.join(TEST_ROOT, "output_FG")
    output_orca_dir = None
    input_device_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_device_dir = os.path.join(TEST_ROOT, "output_FG")

    # ---==============================================---
    # ---========== Input Morphology Details ==========---
    # ---==============================================---

    morphology = "donor_polymer.xml"
    input_sigma = 3.0
    device_morphology = None
    device_components = {}
    overwrite_current_data = True
    random_seed_override = 929292929

    # ---==============================================---
    # ---============= Execution Modules ==============---
    # ---==============================================---

    execute_fine_graining = True  # Requires: None
    execute_molecular_dynamics = False  # Requires: fine_graining
    execute_obtain_chromophores = (
        False)  # Requires: Atomistic morphology, or molecular_dynamics
    execute_ZINDO = False  # Requires: obtain_chromophores
    execute_calculate_transfer_integrals = False  # Requires: execute_ZINDO
    execute_calculate_mobility = False  # Requires: calculate_transfer_integrals
    execute_device_simulation = (
        False
    )  # Requires: calculate_transfer_integrals for all device_components

    # ---==============================================---
    # ---========== Fine Graining Parameters ==========---
    # ---==============================================---

    CG_to_template_dirs = {
        "A": os.path.join(TEST_ROOT, "assets", "donor_polymer"),
        "B": os.path.join(TEST_ROOT, "assets", "donor_polymer"),
        "C": os.path.join(TEST_ROOT, "assets", "donor_polymer"),
    }
    CG_to_template_files = {
        "A": "P3HT_template.xml",
        "B": "P3HT_template.xml",
        "C": "P3HT_template.xml",
    }
    CG_to_template_force_fields = {
        "A": "test_FF.xml",
        "B": "test_FF.xml",
        "C": "test_FF.xml",
    }
    CG_to_template_AAIDs = {
        "A": [0, 1, 2, 3, 4, 24],
        "B": [5, 6, 7, 18, 19, 20, 21, 22, 23],
        "C": [8, 9, 10, 11, 12, 13, 14, 15, 16, 17],
    }
    CG_to_template_bonds = {"bondB": ["C2-C3", 2, 5], "bondC": ["C5-C6", 7, 8]}
    rigid_body_sites = {"A": [0, 1, 2, 3, 4]}
    additional_constraints = [
        ["C1-C10", 3, 25],
        ["C1-C10-C9", 3, 25, 26],
        ["C1-C10-S1", 3, 25, 29],
        ["S1-C1-C10", 4, 3, 25],
        ["C2-C1-C10", 2, 3, 25],
        ["C1-C10-C9-C2", 3, 25, 26, 27],
        ["C1-C10-S1-C1", 3, 25, 29, 28],
        ["S1-C1-C10-S1", 4, 3, 25, 29],
        ["C2-C1-C10-S1", 2, 3, 25, 29],
    ]
    molecule_terminating_connections = {"C1": [[2, 1]], "C10": [[2, 1]]}

    # ---==============================================---
    # ---================= Begin run ==================---
    # ---==============================================---

    parameter_file = os.path.realpath(__file__)
    proc_IDs = hf.get_CPU_cores()
    parameter_names = [
        i for i in dir() if (not i.startswith("__")) and (
            not i.startswith("@")) and (not i.startswith("Test")) and (
                not i.startswith("test")) and (i not in [
                    "run_MorphCT",
                    "helper_functions",
                    "hf",
                    "os",
                    "shutil",
                    "TestCommand",
                    "TEST_ROOT",
                    "setup_module",
                    "teardown_module",
                    "testing_tools",
                    "sys",
                    "pytest",
                ])
    ]
    parameters = {}
    for name in parameter_names:
        parameters[name] = locals()[name]
    run_MorphCT.simulation(
        **parameters)  # Execute MorphCT using these simulation parameters
    # The output dictionary from this fixing
    fix_dict = {}

    # Load the output pickle
    output_pickle_data = hf.load_pickle(
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ))
    fix_dict["output_AA_morphology_dict"] = output_pickle_data[0]
    fix_dict["output_CG_morphology_dict"] = output_pickle_data[1]
    fix_dict["output_CG_to_AAID_master"] = output_pickle_data[2]
    fix_dict["output_parameter_dict"] = output_pickle_data[3]
    fix_dict["output_chromophore_list"] = output_pickle_data[4]

    # Load the expected pickle
    expected_pickle_data = hf.load_pickle(
        os.path.join(
            input_morph_dir,
            "FG",
            morphology.replace(".xml", "_post_fine_graining.pickle"),
        ))
    fix_dict["expected_AA_morphology_dict"] = expected_pickle_data[0]
    fix_dict["expected_CG_morphology_dict"] = expected_pickle_data[1]
    fix_dict["expected_CG_to_AAID_master"] = expected_pickle_data[2]
    fix_dict["expected_parameter_dict"] = expected_pickle_data[3]
    fix_dict["expected_chromophore_list"] = expected_pickle_data[4]
    return fix_dict
예제 #5
0
def run_simulation():
    # ---==============================================---
    # ---======== Directory and File Structure ========---
    # ---==============================================---

    input_morph_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_morph_dir = os.path.join(TEST_ROOT, "output_TI")
    output_orca_dir = None
    input_device_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_device_dir = os.path.join(TEST_ROOT, "output_TI")

    # ---==============================================---
    # ---========== Input Morphology Details ==========---
    # ---==============================================---

    morphology = "donor_polymer.xml"
    input_sigma = 3.0
    device_morphology = None
    device_components = {}
    overwrite_current_data = True
    random_seed_override = 929292929

    # ---==============================================---
    # ---============= Execution Modules ==============---
    # ---==============================================---

    execute_fine_graining = False  # Requires: None
    execute_molecular_dynamics = False  # Requires: fine_graining
    execute_obtain_chromophores = (
        False)  # Requires: Atomistic morphology, or molecular_dynamics
    execute_ZINDO = False  # Requires: obtain_chromophores
    execute_calculate_transfer_integrals = True  # Requires: execute_ZINDO
    execute_calculate_mobility = False  # Requires: calculate_transfer_integrals
    execute_device_simulation = (
        False
    )  # Requires: calculate_transfer_integrals for all device_components

    remove_orca_inputs = False
    remove_orca_outputs = False

    # ---==============================================---
    # ---================= Begin run ==================---
    # ---==============================================---

    parameter_file = os.path.realpath(__file__)
    proc_IDs = hf.get_CPU_cores()
    parameter_names = [
        i for i in dir() if (not i.startswith("__")) and (
            not i.startswith("@")) and (not i.startswith("Test")) and (
                not i.startswith("test")) and (i not in [
                    "run_MorphCT",
                    "helper_functions",
                    "hf",
                    "os",
                    "shutil",
                    "TestCommand",
                    "TEST_ROOT",
                    "setup_module",
                    "teardown_module",
                    "testing_tools",
                    "sys",
                    "pytest",
                ])
    ]
    parameters = {}
    for name in parameter_names:
        parameters[name] = locals()[name]

    # ---==============================================---
    # ---=============== Setup Prereqs ================---
    # ---==============================================---

    try:
        shutil.rmtree(output_morph_dir)
    except OSError:
        pass
    os.makedirs(
        os.path.join(output_morph_dir,
                     os.path.splitext(morphology)[0], "code"))
    shutil.copy(
        os.path.join(
            TEST_ROOT,
            "assets",
            os.path.splitext(morphology)[0],
            "TI",
            morphology.replace(".xml", "_post_execute_ZINDO.pickle"),
        ),
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ),
    )
    shutil.copytree(
        os.path.join(TEST_ROOT, "assets",
                     os.path.splitext(morphology)[0], "TI", "input_orca"),
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "chromophores",
            "input_orca",
        ),
    )
    shutil.copytree(
        os.path.join(TEST_ROOT, "assets",
                     os.path.splitext(morphology)[0], "TI", "output_orca"),
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "chromophores",
            "output_orca",
        ),
    )

    run_MorphCT.simulation(
        **parameters)  # Execute MorphCT using these simulation parameters
    # The output dictionary from this fixing
    fix_dict = {}

    # Load the output pickle
    output_pickle_data = hf.load_pickle(
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ))
    fix_dict["output_AA_morphology_dict"] = output_pickle_data[0]
    fix_dict["output_CG_morphology_dict"] = output_pickle_data[1]
    fix_dict["output_CG_to_AAID_master"] = output_pickle_data[2]
    fix_dict["output_parameter_dict"] = output_pickle_data[3]
    fix_dict["output_chromophore_list"] = output_pickle_data[4]

    # Load the expected pickle
    expected_pickle_data = hf.load_pickle(
        os.path.join(
            input_morph_dir,
            "TI",
            morphology.replace(".xml",
                               "_post_calculate_transfer_integrals.pickle"),
        ))
    fix_dict["expected_AA_morphology_dict"] = expected_pickle_data[0]
    fix_dict["expected_CG_morphology_dict"] = expected_pickle_data[1]
    fix_dict["expected_CG_to_AAID_master"] = expected_pickle_data[2]
    fix_dict["expected_parameter_dict"] = expected_pickle_data[3]
    fix_dict["expected_chromophore_list"] = expected_pickle_data[4]
    return fix_dict
예제 #6
0
def run_simulation():
    # ---==============================================---
    # ---======== Directory and File Structure ========---
    # ---==============================================---

    input_morph_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_morph_dir = os.path.join(TEST_ROOT, "output_MKMC")
    output_orca_dir = None
    input_device_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_device_dir = os.path.join(TEST_ROOT, "output_MKMC")

    # ---==============================================---
    # ---========== Input Morphology Details ==========---
    # ---==============================================---

    morphology = "donor_polymer.xml"
    input_sigma = 3.0
    device_morphology = None
    device_components = {}
    overwrite_current_data = True
    random_seed_override = 929292929

    # ---==============================================---
    # ---============= Execution Modules ==============---
    # ---==============================================---

    execute_fine_graining = False  # Requires: None
    execute_molecular_dynamics = False  # Requires: fine_graining
    execute_obtain_chromophores = (
        False)  # Requires: Atomistic morphology, or molecular_dynamics
    execute_ZINDO = False  # Requires: obtain_chromophores
    execute_calculate_transfer_integrals = False  # Requires: execute_ZINDO
    execute_calculate_mobility = True  # Requires: calculate_transfer_integrals
    execute_device_simulation = (
        False
    )  # Requires: calculate_transfer_integrals for all device_components

    # ---==============================================---
    # ---=== General Kinetic Monte Carlo Parameters ===---
    # ---==============================================---

    # ---=== Universal KMC Parameters ===---
    system_temperature = 290
    use_simple_energetic_penalty = False
    record_carrier_history = True
    use_VRH = True

    # ---=== Mobility Specific KMC Parameters ===---
    number_of_holes_per_simulation_time = 10
    number_of_electrons_per_simulation_time = 0
    hop_limit = 0
    simulation_times = [1.00e-13, 1.00e-12, 1.00e-11]
    combine_KMC_results = True
    use_average_hop_rates = False
    average_intra_hop_rate = 8.07E14
    average_inter_hop_rate = 3.92E14

    # ---==============================================---
    # ---================= Begin run ==================---
    # ---==============================================---

    parameter_file = os.path.realpath(__file__)
    # Force serial running
    proc_IDs = [0]
    parameter_names = [
        i for i in dir() if (not i.startswith("__")) and (
            not i.startswith("@")) and (not i.startswith("Test")) and (
                not i.startswith("test")) and (i not in [
                    "run_MorphCT",
                    "helper_functions",
                    "hf",
                    "os",
                    "shutil",
                    "TestCommand",
                    "TEST_ROOT",
                    "setup_module",
                    "teardown_module",
                    "testing_tools",
                    "sys",
                    "pytest",
                    "pickle",
                ])
    ]
    parameters = {}
    for name in parameter_names:
        parameters[name] = locals()[name]

    # ---==============================================---
    # ---=============== Setup Prereqs ================---
    # ---==============================================---

    try:
        shutil.rmtree(output_morph_dir)
    except OSError:
        pass
    os.makedirs(
        os.path.join(output_morph_dir,
                     os.path.splitext(morphology)[0], "code"))
    shutil.copy(
        os.path.join(
            TEST_ROOT,
            "assets",
            os.path.splitext(morphology)[0],
            "MKMC",
            morphology.replace(".xml",
                               "_post_calculate_transfer_integrals.pickle"),
        ),
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ),
    )

    run_MorphCT.simulation(
        **parameters)  # Execute MorphCT using these simulation parameters
    # The output dictionary from this fixing
    fix_dict = {}

    # Load the output pickle
    output_pickle_data = hf.load_pickle(
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ))
    fix_dict["output_AA_morphology_dict"] = output_pickle_data[0]
    fix_dict["output_CG_morphology_dict"] = output_pickle_data[1]
    fix_dict["output_CG_to_AAID_master"] = output_pickle_data[2]
    fix_dict["output_parameter_dict"] = output_pickle_data[3]
    fix_dict["output_chromophore_list"] = output_pickle_data[4]

    # Load the expected pickle
    expected_pickle_data = hf.load_pickle(
        os.path.join(
            input_morph_dir,
            "MKMC",
            morphology.replace(".xml", "_post_calculate_mobility.pickle"),
        ))
    fix_dict["expected_AA_morphology_dict"] = expected_pickle_data[0]
    fix_dict["expected_CG_morphology_dict"] = expected_pickle_data[1]
    fix_dict["expected_CG_to_AAID_master"] = expected_pickle_data[2]
    fix_dict["expected_parameter_dict"] = expected_pickle_data[3]
    fix_dict["expected_chromophore_list"] = expected_pickle_data[4]
    return fix_dict
def run_simulation():
    # ---==============================================---
    # ---======== Directory and File Structure ========---
    # ---==============================================---

    input_morph_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_morph_dir = os.path.join(TEST_ROOT, "output_RH")
    output_orca_dir = None
    input_device_dir = os.path.join(TEST_ROOT, "assets", "donor_polymer")
    output_device_dir = os.path.join(TEST_ROOT, "output_RH")

    # ---==============================================---
    # ---========== Input Morphology Details ==========---
    # ---==============================================---

    morphology = "donor_polymer.xml"
    input_sigma = 3.0
    device_morphology = None
    device_components = {}
    overwrite_current_data = True
    random_seed_override = 929292929

    # ---==============================================---
    # ---============= Execution Modules ==============---
    # ---==============================================---

    execute_fine_graining = False  # Requires: None
    execute_molecular_dynamics = True  # Requires: fine_graining
    execute_obtain_chromophores = (
        False)  # Requires: Atomistic morphology, or molecular_dynamics
    execute_ZINDO = False  # Requires: obtain_chromophores
    execute_calculate_transfer_integrals = False  # Requires: execute_ZINDO
    execute_calculate_mobility = False  # Requires: calculate_transfer_integrals
    execute_device_simulation = (
        False
    )  # Requires: calculate_transfer_integrals for all device_components

    # ---==============================================---
    # ---=========== Forcefield Parameters ============---
    # ---==============================================---

    CG_to_template_dirs = {
        "A": os.path.join(TEST_ROOT, "assets", "donor_polymer"),
        "B": os.path.join(TEST_ROOT, "assets", "donor_polymer"),
        "C": os.path.join(TEST_ROOT, "assets", "donor_polymer"),
    }
    CG_to_template_force_fields = {
        "A": "test_FF.xml",
        "B": "test_FF.xml",
        "C": "test_FF.xml",
    }
    pair_r_cut = 10.0
    pair_dpd_gamma_val = 0.0

    # ---==============================================---
    # ---===== Molecular Dynamics Phase Parameters ====---
    # ---==============================================---

    number_of_phases = 4
    temperatures = [1.0]
    taus = [1.0]
    pair_types = ["none", "dpd", "lj", "lj", "lj", "lj", "lj", "lj"]
    bond_types = ["harmonic"]
    angle_types = ["harmonic"]
    dihedral_types = ["opls"]
    integration_targets = ["all"]
    timesteps = [1E-3, 1E-3, 1E-7, 1E-4]
    durations = [1E5, 5E4, 1E4, 5E4]
    termination_conditions = ["ke_min", "max_t", "max_t", "max_t"]
    group_anchorings = ["all", "all", "all", "none"]
    dcd_file_write = True
    dcd_file_dumpsteps = [0]

    # ---==============================================---
    # ---================= Begin run ==================---
    # ---==============================================---

    parameter_file = os.path.realpath(__file__)
    proc_IDs = hf.get_CPU_cores()
    parameter_names = [
        i for i in dir() if (not i.startswith("__")) and (
            not i.startswith("@")) and (not i.startswith("Test")) and (
                not i.startswith("test")) and (i not in [
                    "run_MorphCT",
                    "helper_functions",
                    "hf",
                    "os",
                    "shutil",
                    "TestCommand",
                    "TEST_ROOT",
                    "setup_module",
                    "teardown_module",
                    "testing_tools",
                    "sys",
                    "pytest",
                ])
    ]
    parameters = {}
    for name in parameter_names:
        parameters[name] = locals()[name]

    # ---==============================================---
    # ---=============== Setup Prereqs ================---
    # ---==============================================---

    try:
        shutil.rmtree(output_morph_dir)
    except OSError:
        pass
    os.makedirs(
        os.path.join(output_morph_dir,
                     os.path.splitext(morphology)[0], "code"))
    shutil.copy(
        os.path.join(
            TEST_ROOT,
            "assets",
            os.path.splitext(morphology)[0],
            "RH",
            morphology.replace(".xml", "_post_fine_graining.pickle"),
        ),
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ),
    )

    run_MorphCT.simulation(
        **parameters)  # Execute MorphCT using these simulation parameters
    # The output dictionary from this fixing
    fix_dict = {}
    # Load the output pickle
    output_pickle_data = hf.load_pickle(
        os.path.join(
            output_morph_dir,
            os.path.splitext(morphology)[0],
            "code",
            morphology.replace(".xml", ".pickle"),
        ))
    fix_dict["output_AA_morphology_dict"] = output_pickle_data[0]
    fix_dict["output_CG_morphology_dict"] = output_pickle_data[1]
    fix_dict["output_CG_to_AAID_master"] = output_pickle_data[2]
    fix_dict["output_parameter_dict"] = output_pickle_data[3]
    fix_dict["output_chromophore_list"] = output_pickle_data[4]
    # Load the expected pickle
    expected_pickle_data = hf.load_pickle(
        os.path.join(input_morph_dir, "RH",
                     morphology.replace(".xml", "_post_run_HOOMD.pickle")))
    fix_dict["expected_AA_morphology_dict"] = expected_pickle_data[0]
    fix_dict["expected_CG_morphology_dict"] = expected_pickle_data[1]
    fix_dict["expected_CG_to_AAID_master"] = expected_pickle_data[2]
    fix_dict["expected_parameter_dict"] = expected_pickle_data[3]
    fix_dict["expected_chromophore_list"] = expected_pickle_data[4]
    return fix_dict