diff --git a/mosdef_dihedral_fit/dihedral_fit/fit_dihedral_with_gomc.py b/mosdef_dihedral_fit/dihedral_fit/fit_dihedral_with_gomc.py index 51e7bc6..f84347a 100755 --- a/mosdef_dihedral_fit/dihedral_fit/fit_dihedral_with_gomc.py +++ b/mosdef_dihedral_fit/dihedral_fit/fit_dihedral_with_gomc.py @@ -925,7 +925,6 @@ def fit_dihedral_with_gomc( print(f"charmm.combining_rule = {charmm.combining_rule}") - gomc_control.write_gomc_control_file( charmm, f"{gomc_runs_folder_name}/{control_file_name_str}", @@ -2539,13 +2538,15 @@ def fit_dihedral_with_gomc( opls_fit_data_k1_kcal_per_mol_list[opls_q], opls_fit_data_k2_kcal_per_mol_list[opls_q], opls_fit_data_k3_kcal_per_mol_list[opls_q], - opls_fit_data_k4_kcal_per_mol_list[opls_q] + opls_fit_data_k4_kcal_per_mol_list[opls_q], ] # Add the modified k values for the simulation in their correct units, # kcal/mol for LJ and K for Mie or Exp6 opls_k_constant_fitted_q_list_for_ff_modifications = [ - u.unyt_quantity(ki, "kcal/mol").to_value(k_constant_units_str, equivalence="thermal") + u.unyt_quantity(ki, "kcal/mol").to_value( + k_constant_units_str, equivalence="thermal" + ) for ki in opls_k_constant_fitted_q_list_kcal_per_mol ] diff --git a/mosdef_dihedral_fit/tests/test_fit_dihedral_with_gomc.py b/mosdef_dihedral_fit/tests/test_fit_dihedral_with_gomc.py index 977dd18..515c13c 100644 --- a/mosdef_dihedral_fit/tests/test_fit_dihedral_with_gomc.py +++ b/mosdef_dihedral_fit/tests/test_fit_dihedral_with_gomc.py @@ -3316,7 +3316,9 @@ def test_gaussian_log_file_fit_oplsaa_protonated_fragment_CT_CT_C_OH_in_COOH_bad "gaussian/CT_CT_C_OH/input/starting_coords/" "protonated_fragment_CT_CT_C_OH_in_COOH_bad_element_order.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4210,7 +4212,9 @@ def test_zeroed_dihedral_atom_types_not_list(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4243,7 +4247,9 @@ def test_zeroed_dihedral_atom_types_list_1_str(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4276,7 +4282,9 @@ def test_zeroed_dihedral_atom_types_list_2_str(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4309,7 +4317,9 @@ def test_zeroed_dihedral_atom_types_list_1_not_4_strings(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4345,7 +4355,9 @@ def test_zeroed_dihedral_atom_types_list_2_not_4_strings(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4381,7 +4393,9 @@ def test_zeroed_dihedral_atom_types_list_1_not_lenght_4(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4417,7 +4431,9 @@ def test_zeroed_dihedral_atom_types_list_2_not_lenght_4(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4453,7 +4469,9 @@ def test_qm_engine_not_correct_value(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4487,7 +4505,9 @@ def test_qm_engine_not_a_string(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4523,7 +4543,9 @@ def test_atom_type_naming_style_not_correct_value(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4557,7 +4579,9 @@ def test_atom_type_naming_style_not_a_string(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4591,7 +4615,9 @@ def test_gomc_cpu_cores_not_correct_value(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4625,7 +4651,9 @@ def test_gomc_cpu_cores_not_a_int(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4660,7 +4688,9 @@ def test_fit_min_validated_r_squared_not_correct_value_is_0(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4695,7 +4725,9 @@ def test_fit_min_validated_r_squared_not_correct_value_is_1(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4730,7 +4762,9 @@ def test_fit_min_validated_r_squared_not_a_float(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4765,7 +4799,9 @@ def test_fit_validation_r_squared_rtol_not_correct_value_is_0(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4800,7 +4836,9 @@ def test_fit_validation_r_squared_rtol_not_correct_value_is_1(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4835,7 +4873,9 @@ def test_fit_validation_r_squared_rtol_not_a_float(self): get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4891,7 +4931,9 @@ def test_warning_fit_min_validated_r_squared_and_fit_validation_r_squared_rtol_n get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4912,13 +4954,17 @@ def test_warning_fit_min_validated_r_squared_and_fit_validation_r_squared_rtol_n fit_validation_r_squared_rtol=0.0000002, ) - def test_gaussian_log_file_fit_oplsaa_protonated_fragment_CT_CT_C_OH_in_COOH_in_mie_form(self): + def test_gaussian_log_file_fit_oplsaa_protonated_fragment_CT_CT_C_OH_in_COOH_in_mie_form( + self, + ): fit_dihedral_with_gomc( ["CT", "CT", "C", "OH"], get_mosdef_dihedral_fit_fn( "gaussian_style_output_files/CT_CT_C_OH/input/starting_coords/CT_CT_C_3_OH.mol2" ), - get_mosdef_dihedral_fit_fn("gmso_oplsaa_Mie_style_CT_CT_C_OH_in_COOH.xml"), + get_mosdef_dihedral_fit_fn( + "gmso_oplsaa_Mie_style_CT_CT_C_OH_in_COOH.xml" + ), 298.15 * u.Kelvin, gomc_binary_directory, { @@ -4937,122 +4983,122 @@ def test_gaussian_log_file_fit_oplsaa_protonated_fragment_CT_CT_C_OH_in_COOH_in_ ) assert ( - os.path.isfile("all_normalized_energies_in_kcal_per_mol.txt") - is True + os.path.isfile("all_normalized_energies_in_kcal_per_mol.txt") + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_1_2_3_4_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_1_2_3_4_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_1_2_3_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_1_2_3_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_1_2_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_1_2_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_1_3_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_1_3_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_1_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_1_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_2_4_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_2_4_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_2_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_2_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_3_4_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_3_4_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_3_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_3_in_kcal_per_mol.txt" + ) + is True ) assert ( - os.path.isfile( - "all_normalized_energies_OPLS_fit_4_in_kcal_per_mol.txt" - ) - is True + os.path.isfile( + "all_normalized_energies_OPLS_fit_4_in_kcal_per_mol.txt" + ) + is True ) assert os.path.isfile("gomc_raw_energies_in_Kelvin.txt") is True assert ( - os.path.isfile("gomc_raw_OPLS_fit_1_2_3_4_energies_in_Kelvin.txt") - is True + os.path.isfile("gomc_raw_OPLS_fit_1_2_3_4_energies_in_Kelvin.txt") + is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_1_2_3_energies_in_Kelvin.txt") - is True + os.path.isfile("gomc_raw_OPLS_fit_1_2_3_energies_in_Kelvin.txt") + is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_1_2_energies_in_Kelvin.txt") - is True + os.path.isfile("gomc_raw_OPLS_fit_1_2_energies_in_Kelvin.txt") + is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_1_3_energies_in_Kelvin.txt") - is True + os.path.isfile("gomc_raw_OPLS_fit_1_3_energies_in_Kelvin.txt") + is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_1_energies_in_Kelvin.txt") is True + os.path.isfile("gomc_raw_OPLS_fit_1_energies_in_Kelvin.txt") is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_2_4_energies_in_Kelvin.txt") - is True + os.path.isfile("gomc_raw_OPLS_fit_2_4_energies_in_Kelvin.txt") + is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_2_energies_in_Kelvin.txt") is True + os.path.isfile("gomc_raw_OPLS_fit_2_energies_in_Kelvin.txt") is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_3_4_energies_in_Kelvin.txt") - is True + os.path.isfile("gomc_raw_OPLS_fit_3_4_energies_in_Kelvin.txt") + is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_3_energies_in_Kelvin.txt") is True + os.path.isfile("gomc_raw_OPLS_fit_3_energies_in_Kelvin.txt") is True ) assert ( - os.path.isfile("gomc_raw_OPLS_fit_4_energies_in_Kelvin.txt") is True + os.path.isfile("gomc_raw_OPLS_fit_4_energies_in_Kelvin.txt") is True ) assert ( - os.path.isfile( - "opls_all_single_fit_dihedral_k_constants_figure.pdf" - ) - is True + os.path.isfile( + "opls_all_single_fit_dihedral_k_constants_figure.pdf" + ) + is True ) assert ( - os.path.isfile("opls_all_summed_dihedrals_k_constants_figure.pdf") - is True + os.path.isfile("opls_all_summed_dihedrals_k_constants_figure.pdf") + is True ) assert ( - os.path.isfile("opls_dihedral_k_constants_fit_energy.txt") is True + os.path.isfile("opls_dihedral_k_constants_fit_energy.txt") is True ) assert ( - os.path.isfile("periodic_dihedral_k_constants_fit_energy.txt") - is True + os.path.isfile("periodic_dihedral_k_constants_fit_energy.txt") + is True ) assert os.path.isfile("RB_torsion_k_constants_fit_energy.txt") is True @@ -5576,4 +5622,3 @@ def test_gaussian_log_file_fit_oplsaa_protonated_fragment_CT_CT_C_OH_in_COOH_in_ atol=0.02, rtol=0.08, ) -