@@ -950,8 +950,7 @@ RECURSIVE SUBROUTINE qmmm_energy_and_forces(force_env,calc_force,require_consist
950950 error,failure)
951951 ENDIF
952952
953- ! Possibly translate the system
954-
953+ ! Possibly translate the system
955954 CALL apply_qmmm_translate(force_env, error)
956955
957956 DO isubf=1, SIZE(force_env%sub_force_env)
@@ -1095,11 +1094,11 @@ RECURSIVE SUBROUTINE qmmm_energy_and_forces_low(force_env,calc_force,error)
10951094 routineP = moduleN//' :' //routineN
10961095
10971096 CHARACTER(LEN=default_string_length) :: description, iter
1098- INTEGER :: ip, nres, output_unit
1097+ INTEGER :: ip, j, nres, output_unit
10991098 INTEGER, DIMENSION(:), POINTER :: qm_atom_index
1100- LOGICAL :: calculate_forces, failure , &
1101- qmmm_added_chrg, qmmm_link , &
1102- qmmm_link_imomm
1099+ LOGICAL :: calculate_forces, check , &
1100+ failure, qmmm_added_chrg , &
1101+ qmmm_link, qmmm_link_imomm
11031102 REAL(KIND=dp) :: energy_mm, energy_qm
11041103 REAL(KIND=dp), DIMENSION(3) :: dip_mm, dip_qm, dip_qmmm, &
11051104 max_coord, min_coord
@@ -1147,6 +1146,19 @@ RECURSIVE SUBROUTINE qmmm_energy_and_forces_low(force_env,calc_force,error)
11471146
11481147 particles_mm => subsys_mm%particles%els
11491148 particles_qm => subsys_qm%particles%els
1149+
1150+ DO j=1,3
1151+ IF (qm_cell%perd(j)==1) CYCLE
1152+ DO ip=1, SIZE(particles_qm)
1153+ check = (DOT_PRODUCT(qm_cell%h_inv(j,:),particles_qm(ip)%r) >= 0.0) .AND. &
1154+ (DOT_PRODUCT(qm_cell%h_inv(j,:),particles_qm(ip)%r) <= 1.0)
1155+ CALL cp_assert(check, cp_failure_level, cp_assertion_failed, routinep,&
1156+ "QM/MM QM atoms must be fully contained in the same image of the QM box "//&
1157+ "- No wrapping of coordinates is allowed! "//&
1158+ CPSourceFileRef,&
1159+ error)
1160+ END DO
1161+ END DO
11501162
11511163 ! If present QM/MM links (just IMOMM) correct the position of the qm-link atom
11521164 IF (qmmm_link_imomm) CALL qmmm_link_Imomm_coord(qmmm_links, particles_qm, qm_atom_index, error)
0 commit comments