diff --git a/src/eip_environment.F b/src/eip_environment.F index b6e52d2d06..e718b71d7d 100644 --- a/src/eip_environment.F +++ b/src/eip_environment.F @@ -287,7 +287,7 @@ CONTAINS ! *** Print the atomic coordinates CALL write_qs_particle_coordinates(particle_set, cell=cell, & subsys_section=subsys_section, & - error=error) + label="EIP",error=error) CALL write_particle_distances(particle_set, cell=cell, & subsys_section=subsys_section, & error=error) diff --git a/src/force_env_methods.F b/src/force_env_methods.F index a08551741b..5eb5a408f0 100644 --- a/src/force_env_methods.F +++ b/src/force_env_methods.F @@ -1507,10 +1507,10 @@ END SUBROUTINE mixed_energy_forces CHARACTER(len=*), PARAMETER :: routineN = 'get_subsys_map_index', & routineP = moduleN//':'//routineN - INTEGER :: i, ival, j, jval, k, n_rep, & - n_rep_loc, n_rep_sys, stat, & - tmp - INTEGER, DIMENSION(:), POINTER :: index_glo, index_loc + INTEGER :: i, iatom, ival, j, jval, k, & + n_rep, n_rep_loc, n_rep_map, & + n_rep_sys, stat, tmp + INTEGER, DIMENSION(:), POINTER :: index_glo, index_loc, list LOGICAL :: check, explicit, failure TYPE(section_vals_type), POINTER :: fragments_loc, fragments_sys, & map_force_ev, map_full_sys @@ -1542,30 +1542,58 @@ END SUBROUTINE mixed_energy_forces fragments_sys => section_vals_get_subs_vals(map_full_sys,"FRAGMENT",error=error) fragments_loc => section_vals_get_subs_vals(map_force_ev,"FRAGMENT",i_rep_section=i,error=error) !Perform few check on the structure of the input mapping section. as provided by the user - CALL section_vals_get(fragments_loc, explicit=explicit, n_repetition=n_rep_loc, error=error) - CPPrecondition(explicit,cp_failure_level,routineP,error,failure) + CALL section_vals_get(fragments_loc, n_repetition=n_rep_loc, error=error) CALL section_vals_get(fragments_sys, explicit=explicit, n_repetition=n_rep_sys, error=error) CPPrecondition(explicit,cp_failure_level,routineP,error,failure) CPPrecondition(n_rep_sys>=n_rep_loc,cp_failure_level,routineP,error,failure) - !Loop over the fragment of the force_eval - DO i = 1, n_rep_loc - CALL section_vals_val_get(fragments_loc,"_SECTION_PARAMETERS_",i_rep_section=i,i_val=ival,error=error) - CALL section_vals_val_get(fragments_loc,"MAP",i_rep_section=i,i_val=jval,error=error) - ! Index corresponding to the mixed_force_eval fragment - DO j = 1, n_rep_sys - CALL section_vals_val_get(fragments_sys,"_SECTION_PARAMETERS_",i_rep_section=j,i_val=tmp,error=error) - IF (tmp==jval) EXIT - END DO - CPPrecondition(j<=n_rep_sys,cp_failure_level,routineP,error,failure) - CALL section_vals_val_get(fragments_loc,"_DEFAULT_KEYWORD_",i_rep_section=i,i_vals=index_loc,error=error) - CALL section_vals_val_get(fragments_sys,"_DEFAULT_KEYWORD_",i_rep_section=j,i_vals=index_glo,error=error) - check = ((index_loc(2)-index_loc(1))==(index_glo(2)-index_glo(1))) + IF (n_rep_loc==0) THEN + NULLIFY(list) + ! We expect an easier syntax in this case.. + CALL section_vals_val_get(map_force_ev,"DEFINE_FRAGMENTS",i_rep_section=i,n_rep_val=n_rep_map,& + error=error) + check = (n_rep_map/=0) CPPrecondition(check,cp_failure_level,routineP,error,failure) - ! Now let's build the real mapping - DO k = 0, index_loc(2)-index_loc(1) - map_index(index_loc(1)+k) = index_glo(1)+k + CALL section_vals_val_get(map_force_ev,"DEFINE_FRAGMENTS",i_rep_section=i,i_vals=list,& + error=error) + CPPrecondition(SIZE(list)>0,cp_failure_level,routineP,error,failure) + iatom = 0 + DO i = 1, SIZE(list) + jval = list(i) + DO j = 1, n_rep_sys + CALL section_vals_val_get(fragments_sys,"_SECTION_PARAMETERS_",i_rep_section=j,i_val=tmp,error=error) + IF (tmp==jval) EXIT + END DO + CALL section_vals_val_get(fragments_sys,"_DEFAULT_KEYWORD_",i_rep_section=j,i_vals=index_glo,error=error) + DO k = 0, index_glo(2)-index_glo(1) + iatom = iatom + 1 + CPPrecondition(iatom<=natom,cp_failure_level,routineP,error,failure) + map_index(iatom) = index_glo(1)+k + END DO END DO - END DO + check = (iatom==natom) + CPPrecondition(check,cp_failure_level,routineP,error,failure) + ELSE + ! General syntax.. + !Loop over the fragment of the force_eval + DO i = 1, n_rep_loc + CALL section_vals_val_get(fragments_loc,"_SECTION_PARAMETERS_",i_rep_section=i,i_val=ival,error=error) + CALL section_vals_val_get(fragments_loc,"MAP",i_rep_section=i,i_val=jval,error=error) + ! Index corresponding to the mixed_force_eval fragment + DO j = 1, n_rep_sys + CALL section_vals_val_get(fragments_sys,"_SECTION_PARAMETERS_",i_rep_section=j,i_val=tmp,error=error) + IF (tmp==jval) EXIT + END DO + CPPrecondition(j<=n_rep_sys,cp_failure_level,routineP,error,failure) + CALL section_vals_val_get(fragments_loc,"_DEFAULT_KEYWORD_",i_rep_section=i,i_vals=index_loc,error=error) + CALL section_vals_val_get(fragments_sys,"_DEFAULT_KEYWORD_",i_rep_section=j,i_vals=index_glo,error=error) + check = ((index_loc(2)-index_loc(1))==(index_glo(2)-index_glo(1))) + CPPrecondition(check,cp_failure_level,routineP,error,failure) + ! Now let's build the real mapping + DO k = 0, index_loc(2)-index_loc(1) + map_index(index_loc(1)+k) = index_glo(1)+k + END DO + END DO + END IF END IF END SUBROUTINE get_subsys_map_index diff --git a/src/input_cp2k.F b/src/input_cp2k.F index 87ec59b4ba..1528f012fa 100644 --- a/src/input_cp2k.F +++ b/src/input_cp2k.F @@ -1680,6 +1680,16 @@ END SUBROUTINE create_cpot_section n_keywords=1, n_subsections=0, repeats=.TRUE., required=.TRUE.,& error=error) + CALL keyword_create(keyword, name="DEFINE_FRAGMENTS",& + description="Specify the fragments definition of the force_eval through the fragments of the"//& + " force_eval_mixed. This avoids the pedantic definition of the fragments for the force_eval,"//& + " assuming the order of the fragments for the specified force_eval is the same as the sequence "//& + " of integers provided. Easier to USE should be preferred to the specification of the single fragments.",& + usage="DEFINE_FRAGMENTS .. ", type_of_var=integer_t, n_var=-1,& + error=error) + CALL section_add_keyword(sub2section,keyword,error=error) + CALL keyword_release(keyword,error=error) + CALL keyword_create(keyword, name="_SECTION_PARAMETERS_",& description="Defines the index of the force_eval for which fragments and mappings are provided",& usage="", type_of_var=integer_t, n_var=1, required=.TRUE.,error=error) diff --git a/src/kg_environment.F b/src/kg_environment.F index 5e148e2ab2..2b13526cf3 100644 --- a/src/kg_environment.F +++ b/src/kg_environment.F @@ -295,7 +295,7 @@ CONTAINS CALL write_total_numbers(atomic_kind_set,particle_set,kg_env%input,error) ! Print the atomic coordinates - CALL write_qs_particle_coordinates(particle_set,cell,subsys_section,error) + CALL write_qs_particle_coordinates(particle_set,cell,subsys_section,label="KIM-GORDON",error=error) ! Print the interatomic distances *** CALL write_particle_distances(particle_set,cell,subsys_section,error) diff --git a/src/particle_types.F b/src/particle_types.F index 51c7207a89..262c28a20a 100644 --- a/src/particle_types.F +++ b/src/particle_types.F @@ -661,7 +661,7 @@ END SUBROUTINE clone_particle unit_of_length_name=unit_of_length_name) WRITE (UNIT=iw,FMT="(/,/,T2,A)")& - "ATOMIC COORDINATES IN "//TRIM(unit_of_length_name) + "MODULE FIST: ATOMIC COORDINATES IN "//TRIM(unit_of_length_name) WRITE (UNIT=iw,& FMT="(/,T3,A,7X,2(A1,11X),A1,8X,A8,5X,A6,/)")& "Atom Kind ATM_TYP","X","Y","Z"," q(eff)"," Mass" @@ -686,7 +686,7 @@ END SUBROUTINE clone_particle END SUBROUTINE write_fist_particle_coordinates - SUBROUTINE write_qs_particle_coordinates(particle_set,cell,subsys_section,error) + SUBROUTINE write_qs_particle_coordinates(particle_set,cell,subsys_section,label,error) ! Purpose: Write the atomic coordinates to the output unit. ! History: - Creation (05.06.2000,MK) @@ -695,6 +695,7 @@ END SUBROUTINE clone_particle POINTER :: particle_set TYPE(cell_type), POINTER :: cell TYPE(section_vals_type), POINTER :: subsys_section + CHARACTER(LEN=*), INTENT(IN) :: label TYPE(cp_error_type), INTENT(INOUT) :: error CHARACTER(LEN=2) :: element_symbol @@ -715,7 +716,7 @@ END SUBROUTINE clone_particle unit_of_length_name=unit_of_length_name) WRITE (UNIT=iw,FMT="(/,/,T2,A)")& - "ATOMIC COORDINATES IN "//TRIM(unit_of_length_name) + "MODULE "//TRIM(label)//": ATOMIC COORDINATES IN "//TRIM(unit_of_length_name) WRITE (UNIT=iw,& FMT="(/,T3,A,7X,2(A1,11X),A1,8X,A8,5X,A6,/)")& "Atom Kind Element","X","Y","Z"," Z(eff)"," Mass" diff --git a/src/qs_environment.F b/src/qs_environment.F index a425245cc3..f93fd9a2a8 100644 --- a/src/qs_environment.F +++ b/src/qs_environment.F @@ -26,21 +26,19 @@ !****************************************************************************** MODULE qs_environment - USE bibliography, ONLY: cite_reference, Iannuzzi2007 USE atomic_kind_list_types, ONLY: atomic_kind_list_create,& atomic_kind_list_release,& atomic_kind_list_type USE atomic_kind_types, ONLY: atomic_kind_type,& check_atomic_kind_set,& - get_atomic_kind,& get_atomic_kind_set,& init_atomic_kind_set,& init_gapw_basis_set,& read_atomic_kind_set,& write_atomic_kind_set,& write_gto_basis_sets - USE basis_set_types, ONLY: get_gto_basis_set,& - gto_basis_set_type + USE bibliography, ONLY: Iannuzzi2007,& + cite_reference USE cell_types, ONLY: cell_clone,& cell_create,& cell_release,& @@ -212,6 +210,7 @@ CONTAINS CHARACTER(len=*), PARAMETER :: routineN = 'qs_init', & routineP = moduleN//':'//routineN + INTEGER :: max_set, natom LOGICAL :: do_et, do_hf, harris_flag, & my_qmmm, my_qmmm_periodic, & use_ref_cell @@ -233,8 +232,6 @@ CONTAINS POINTER :: particle_set TYPE(section_vals_type), POINTER :: cell_section, colvar_section, & et_coupling_section, harris_section, hf_section, kind_section - INTEGER :: iatom, natom, nseta, iset,& - max_set NULLIFY(my_subsystem, molecule_kind_set, molecule_set, atomic_kind_set,& particle_set,atomic_kinds,particles,mols,mol_kinds,my_cell,my_cell_ref,& @@ -921,7 +918,7 @@ CONTAINS CALL write_total_numbers(atomic_kind_set,particle_set,qs_env%input,error) ! Print the atomic coordinates - CALL write_qs_particle_coordinates(particle_set,cell,subsys_section,error) + CALL write_qs_particle_coordinates(particle_set,cell,subsys_section,label="QUICKSTEP",error=error) ! Print the interatomic distances CALL write_particle_distances(particle_set,cell,subsys_section,error) diff --git a/tests/FE/regtest-1/Solv_alch_chng_simpl.inp b/tests/FE/regtest-1/Solv_alch_chng_simpl.inp new file mode 100644 index 0000000000..cce10243d3 --- /dev/null +++ b/tests/FE/regtest-1/Solv_alch_chng_simpl.inp @@ -0,0 +1,164 @@ +&MULTIPLE_FORCE_EVALS + FORCE_EVAL_ORDER 2 3 + MULTIPLE_SUBSYS T +&END +&FORCE_EVAL + METHOD MIXED + &MIXED + MIXING_TYPE GENMIX + &GENERIC + # X: Energy force_eval 2 + # Y: Energy force_eval 3 + MIXING_FUNCTION k*X+(1.0-k)*Y + VARIABLES X Y + PARAMETERS k + VALUES 0.5 + &END + &MAPPING + &FORCE_EVAL_MIXED + &FRAGMENT 1 + 1 6 + &END + &FRAGMENT 2 + 7 16 + &END + &FRAGMENT 3 + 17 22 + &END + &FRAGMENT 4 + 23 33 + &END + &FRAGMENT 5 + 34 1851 + &END + &END + &FORCE_EVAL 1 + DEFINE_FRAGMENTS 1 2 3 5 + &END + &FORCE_EVAL 2 + DEFINE_FRAGMENTS 1 4 3 5 + &END + &END + &END + &SUBSYS + &TOPOLOGY + CONNECTIVITY OFF + COORDINATE PDB + COORD_FILE_NAME full.pdb + &END TOPOLOGY + &CELL + ABC 30.9751780 30.8599250 30.7278700 + UNIT ANGSTROM + &END CELL + &END SUBSYS +&END FORCE_EVAL +&FORCE_EVAL + METHOD FIST + &MM + &FORCEFIELD + PARM_FILE_NAME ala.pot + parmtype CHM + &SPLINE + EMAX_SPLINE 100000000.0 + &END + &END FORCEFIELD + &POISSON + &EWALD + EWALD_TYPE spme + ALPHA .5 + GMAX 36 + O_SPLINE 6 + &END EWALD + &END POISSON + &END MM + &SUBSYS + &TOPOLOGY + CONNECTIVITY PSF + CONN_FILE_NAME ala.psf + COORDINATE PDB + COORD_FILE_NAME ala.pdb + &END TOPOLOGY + &CELL + ABC 30.9751780 30.8599250 30.7278700 + UNIT ANGSTROM + &END CELL + &END SUBSYS +&END FORCE_EVAL +&FORCE_EVAL + METHOD FIST + &MM + &FORCEFIELD + PARM_FILE_NAME ser.pot + parmtype CHM + &SPLINE + EMAX_SPLINE 100000000.0 + &END + &END FORCEFIELD + &POISSON + &EWALD + EWALD_TYPE spme + ALPHA .5 + GMAX 36 + O_SPLINE 6 + &END EWALD + &END POISSON + &END MM + &SUBSYS + &TOPOLOGY + CONNECTIVITY PSF + CONN_FILE_NAME ser.psf + COORDINATE PDB + COORD_FILE_NAME ser.pdb + &END TOPOLOGY + &CELL + ABC 30.9751780 30.8599250 30.7278700 + UNIT ANGSTROM + &END CELL + &END SUBSYS +&END FORCE_EVAL +&GLOBAL + FFTLIB FFTSG + PROJECT DDG_SOLVATION + RUN_TYPE MD + PRINT_LEVEL LOW +&END GLOBAL +&MOTION + &MD + ENSEMBLE NVE + STEPS 20 + TIMESTEP 0.5 + TEMPERATURE 200.0 + &NOSE + LENGTH 3 + YOSHIDA 3 + TIMECON 300 + MTS 2 + &END NOSE + &PRINT + &ENERGY + EACH 1 + &END + &END + &END MD + &PRINT + &TRAJECTORY + EACH 100 + &END + &VELOCITIES OFF + &END + &FORCES OFF + &END + &RESTART_HISTORY OFF + &END + &RESTART + EACH 10 + &END + &END + &FREE_ENERGY + METHOD AC + &ALCHEMICAL_CHANGE + PARAMETER k + &END + &END +&END MOTION + diff --git a/tests/FE/regtest-1/TEST_FILES b/tests/FE/regtest-1/TEST_FILES index 2bceaf2517..015fa2505b 100644 --- a/tests/FE/regtest-1/TEST_FILES +++ b/tests/FE/regtest-1/TEST_FILES @@ -6,3 +6,4 @@ # Solv_alch_chng.inp 2 Solv_alch_chng_dist.inp 2 +Solv_alch_chng_simpl.inp 2