Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nroot selectroot handling #126

Merged
merged 12 commits into from
Dec 15, 2023
Merged
26 changes: 9 additions & 17 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ pytest --all
142
nelec
2
nroot
3
selectroot
2
totsym
3
eshift
Expand All @@ -283,12 +279,8 @@ pytest --all
574
nelec
12
nroot
10
totsym
33
selectroot
1
eshift
0.0
diracver
Expand All @@ -313,8 +305,6 @@ Input for CASCI and CASPT2
ninact : the number of inactive spinors
nact : the number of active spinors
nsec : the number of secondary spinors
nroot : the number of roots
selectroot : which root do you want to obtain
totsym : total symmetry (ex. 5 for Ag in C2h closed shell)
diracver : DIRAC version
end : The identifier at the end of the input file
Expand All @@ -325,18 +315,20 @@ noccg : The number of occupied spinors (gerade)
noccu : The number of occupied spinors (ungerade)

[optional parameters]
eshift : for real shift (if you don't write, it will be 0)
ras1 : RAS1 spinor list (row 1) and the maximum number of hole allowed in ras1(row 2)
nroot : the number of roots (default: 10, if the number of CASCI/RASCI determinants is less than 10, it will be replaced by the number of CASCI/RASCI determinants)
selectroot : which root do you want to calculate RASPT2/CASPT2 energy? (default: 1, the lowest root)
eshift : for real shift (default: 0)
ras1 : RAS1 spinor list (row 1)and the maximum number of hole allowed in ras1(row 2)
ras2 : RAS2 spinor list
ras3 : RAS3 spinor list (row 1) and the maximum number of electrons in ras3(row2)
minholeras1 : The minimum number of hole in ras1 (If you don't write, it will be 0)
minholeras1 : The minimum number of hole in ras1 (default: 0)
calctype : The type of calculation. only CASCI or DMRG are currently supported. (if you don't write, it will be CASCI(default))

[optional parameters (IVO)]
nhomo : The number of HOMO-like spinors
nvcut : The number of virtual cut MO (This option is for molecules without inversion center symmetry)
nvcutg : The number of virtual cut spinors (gerade)
nvcutu : The number of virtual cut spinors (ungerade)
nhomo : The number of HOMO-like spinors (default: 0)
nvcut : The number of virtual cut MO (default: 0, This option is for molecules without inversion center symmetry)
nvcutg : The number of virtual cut MO (default: 0, gerade)
nvcutu : The number of virtual cut MO (default: 0, ungerade)
```

### インプットファイルの仕様
Expand Down
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@ The following custom CMake build options are currently supported
142
nelec
2
nroot
3
selectroot
2
totsym
3
eshift
Expand All @@ -281,12 +277,8 @@ The following custom CMake build options are currently supported
574
nelec
12
nroot
10
totsym
33
selectroot
1
eshift
0.0
diracver
Expand All @@ -312,8 +304,6 @@ ninact : the number of inactive spinors
nact : the number of active spinors
nsec : the number of secondary spinors
nelec : the number of active electrons in active space
nroot : the number of roots
selectroot : which root do you want to obtain
totsym : total symmetry (ex. 5 for Ag in C2h closed shell)
diracver : DIRAC version
end : The identifier at the end of the input file
Expand All @@ -324,18 +314,20 @@ noccg : The number of occupied MO (gerade)
noccu : The number of occupied MO (ungerade)

[optional parameters]
eshift : for real shift (if you don't write, it will be 0)
nroot : the number of roots (default: 10, if the number of CASCI/RASCI determinants is less than 10, it will be replaced by the number of CASCI/RASCI determinants)
selectroot : which root do you want to calculate RASPT2/CASPT2 energy? (default: 1, the lowest root)
eshift : for real shift (default: 0)
ras1 : RAS1 spinor list (row 1)and the maximum number of hole allowed in ras1(row 2)
ras2 : RAS2 spinor list
ras3 : RAS3 spinor list (row 1) and the maximum number of electrons in ras3(row2)
minholeras1 : The minimum number of hole in ras1 (If you don't write, it will be 0)
minholeras1 : The minimum number of hole in ras1 (default: 0)
calctype : The type of calculation. only CASCI or DMRG are currently supported. (if you don't write, it will be CASCI(default))

[optional parameters (IVO)]
nhomo : The number of HOMO-like spinors
nvcut : The number of virtual cut MO (This option is for molecules without inversion center symmetry)
nvcutg : The number of virtual cut MO (gerade)
nvcutu : The number of virtual cut MO (ungerade)
nhomo : The number of HOMO-like spinors (default: 0)
nvcut : The number of virtual cut MO (default: 0, This option is for molecules without inversion center symmetry)
nvcutg : The number of virtual cut MO (default: 0, gerade)
nvcutu : The number of virtual cut MO (default: 0, ungerade)
```

### Input file specification
Expand Down
2 changes: 1 addition & 1 deletion src/module_global_variables.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MODULE module_global_variables
! eshift : Real shift
! dirac_version : DIRAC version
integer :: ninact, nact, nsec, nelec
integer :: nroot, selectroot
integer :: nroot = 10, selectroot = 1
integer :: totsym, ncore
real(8) :: eshift = 0.0d+00 ! default: 0.0
character :: calctype*5 = "casci" ! dmrg or casci(default)
Expand Down
28 changes: 21 additions & 7 deletions src/read_input_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ subroutine init_essential_variables
call add_essential_input("nact")
call add_essential_input("nsec")
call add_essential_input("nelec")
call add_essential_input("nroot")
call add_essential_input("selectroot")
call add_essential_input("totsym")
call add_essential_input("diracver")
end subroutine init_essential_variables
Expand Down Expand Up @@ -60,6 +58,7 @@ subroutine read_input(unit_num)

call check_all_essential_inputs_specified
call set_global_index
call validate_nroot_selectroot
! Check the RAS configuration
if (ras1_size /= 0 .or. ras2_size /= 0 .or. ras3_size /= 0) call check_ras_is_valid

Expand Down Expand Up @@ -96,15 +95,13 @@ subroutine read_keyword_and_value(unit_num, string)
call update_esesential_input("nelec", .true.)

case ("nroot")
call read_an_integer(unit_num, 0, input_intmax, nroot)
call update_esesential_input("nroot", .true.)
call read_an_integer(unit_num, 1, input_intmax, nroot)

case ("selectroot")
call read_an_integer(unit_num, 0, input_intmax, selectroot)
call update_esesential_input("selectroot", .true.)
call read_an_integer(unit_num, 1, input_intmax, selectroot)

case ("totsym")
call read_an_integer(unit_num, 0, input_intmax, totsym)
call read_an_integer(unit_num, 1, input_intmax, totsym)
call update_esesential_input("totsym", .true.)

case ("ncore")
Expand Down Expand Up @@ -732,6 +729,23 @@ subroutine is_comment_line(string, is_comment)

end subroutine is_comment_line

subroutine validate_nroot_selectroot
use module_global_variables, only: rank, nroot, selectroot
implicit none
if (nroot < selectroot) then
if (rank == 0) then
print *, "Warning: nroot < selectroot"
print '(a,i0)', "nroot = ", nroot
print '(a,i0)', "selectroot = ", selectroot
print *, "this is not an error, but it is not recommended"
print '(a,i0,a)', "because ", selectroot, "th RASCI/CASCI energy will not be displayed to the output file."
print *, "Threfore, explicitly replace the number of selectroot to the number of nroot."
print '(a,i0)', "new nroot = ", selectroot
end if
nroot = selectroot
end if
end subroutine validate_nroot_selectroot

subroutine check_ras_is_valid
use module_global_variables
implicit none
Expand Down
29 changes: 29 additions & 0 deletions src/search_cas_configuration.f90
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ SUBROUTINE search_cas_configuration
print *, 'totsym = ', totsym
print *, 'ndet = ', ndet
end if

call validate_ndet_and_input_parameters()
contains

function find_next_determinant() result(next_determinant)
Expand Down Expand Up @@ -138,4 +140,31 @@ logical function is_cas_determinant()
end if
end if
end function is_cas_determinant

subroutine validate_ndet_and_input_parameters()
implicit none
if (ndet < selectroot) then
if (rank == 0) then
print *, "ERROR: ndet < selectroot"
print '(A,I0,A)', "Cannot calculate ", selectroot, "th RASCI/CASCI energy"
print '(A,I0,A,I0)', "because the number of CASCI determinant is ", ndet, " and it is less than ", selectroot
print *, "Please increase the number of active orbitals or the number of electrons"
print *, "or decrease the number of selected root."
print *, "Exit the program."
end if
call stop_with_errorcode(1)
end if

if (ndet < nroot) then
if (rank == 0) then
print *, "WARNING: ndet < nroot"
print '(A,I0,A)', "Cannot print ", nroot, "th RASCI/CASCI energy"
print '(A,I0,A,I0)', "because the number of CASCI determinant is ", ndet, " and it is less than ", nroot
print *, "Therefore, explicitly replace nroot with the number of CASCI determinant."
print *, "new nroot = ", ndet
end if
nroot = ndet
end if
end subroutine validate_ndet_and_input_parameters

end subroutine search_cas_configuration
2 changes: 1 addition & 1 deletion test/dev/ivo_c32h_ar_with_kappa_dev/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*DFPCMONEW*
ivo_c32h_ar_dev.ivo.out
ivo_c32h_ar_with_kappa_dev.ivo.out
latest_passed.*
!reference.*
8 changes: 2 additions & 6 deletions test/unit_test/ras3_bitcheck/active.inp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ nsec
nelec
4
totsym
0
nroot
0
selectroot
0
1
diracver
0
22
ras1
1,2
2
Expand Down