diff --git a/CPV/input.f90 b/CPV/input.f90 index eb229ca6c..42eac2594 100644 --- a/CPV/input.f90 +++ b/CPV/input.f90 @@ -836,7 +836,7 @@ MODULE input etot_conv_thr, ekin_conv_thr, nspin, f_inp, nelup, neldw, nbnd, & nelec, tprnks, ks_path, press, cell_damping, cell_dofree, tf_inp, & refg, greash, grease, greasp, epol, efield, tcg, maxiter, etresh, & - passop + passop, tot_charge ! USE input_parameters, ONLY : wf_efield, wf_switch, sw_len, efx0, efy0, & efz0, efx1, efy1, efz1, wfsd, wfdt, maxwfdt, & @@ -1006,7 +1006,8 @@ MODULE input CALL ks_states_init( nspin, tprnks, tprnks_empty ) CALL electrons_base_initval( zv, na_inp, ntyp, nelec, nelup, & - neldw, nbnd, nspin, occupations, f_inp ) + neldw, nbnd, nspin, occupations, f_inp, & + tot_charge ) CALL electrons_setup( empty_states_nbnd, emass, emass_cutoff, nkstot ) diff --git a/Doc/INPUT_CP b/Doc/INPUT_CP index ff2246859..3c628ece4 100644 --- a/Doc/INPUT_CP +++ b/Doc/INPUT_CP @@ -210,6 +210,10 @@ nelec INTEGER number of electron in the unit cell. If not specified it is read from the pseudopotential +tot_charge INTEGER ( default = 0 ) + total system charge. Used if nelec is not specified, + otherwise it is ignored. + nbnd INTEGER ( default = nelec / 2 ) number of electronic states (bands) to be calculated. diff --git a/Modules/electrons_base.f90 b/Modules/electrons_base.f90 index 897eab346..db271b0c0 100644 --- a/Modules/electrons_base.f90 +++ b/Modules/electrons_base.f90 @@ -39,7 +39,7 @@ SUBROUTINE electrons_base_initval( zv_ , na_ , nsp_ , nelec_ , nelup_ , neldw_ , nbnd_ , & - nspin_ , occupations_ , f_inp ) + nspin_ , occupations_ , f_inp, tot_charge_ ) USE constants, ONLY: eps8 USE io_global, ONLY: stdout @@ -51,7 +51,7 @@ INTEGER, INTENT(IN) :: nbnd_ , nspin_ CHARACTER(LEN=*), INTENT(IN) :: occupations_ REAL(DP), INTENT(IN) :: f_inp(:,:) - REAL(DP) :: nelec, nelup, neldw, ocp, fsum + REAL(DP) :: nelec, nelup, neldw, ocp, fsum, tot_charge_ INTEGER :: iss, i, in nspin = nspin_ @@ -63,6 +63,7 @@ DO i = 1, nsp_ nelec = nelec + na_ ( i ) * zv_ ( i ) END DO + nelec = nelec - tot_charge_ END IF IF( nelup_ > 0.0d0 .AND. neldw_ > 0.0d0 ) THEN diff --git a/Modules/input_parameters.f90 b/Modules/input_parameters.f90 index 25226dd9e..41ff2e910 100644 --- a/Modules/input_parameters.f90 +++ b/Modules/input_parameters.f90 @@ -337,6 +337,9 @@ MODULE input_parameters ! number of electrons, this parameter is MANDATORY in FPMD ! may be fractionary in PW, but not in CP and FPMD ! + REAL(DP):: tot_charge = 0.0d0 + ! total system charge + REAL(DP) :: ecutwfc = 0.0d0 ! energy cutoff for wave functions in k-space ( in Rydbergs ) ! this parameter is MANDATORY in FPMD @@ -552,7 +555,8 @@ MODULE input_parameters #endif noncolin, lspinorb, lambda, angle1, angle2, report, & constrained_magnetization, B_field, fixed_magnetization, & - sic, sic_epsilon, force_pairing, sic_alpha + sic, sic_epsilon, force_pairing, sic_alpha, & + tot_charge !=----------------------------------------------------------------------------=!