Open NastaMauger opened 1 month ago
Hi, There is an input option"printalldeterminants" that will ensure all determinants are printed. You have to be careful because for large problems the size of the output file can become very large. There are other binary format files that we use to read/write determinants.
The number of determinants are already printed in each iteration. An example of an iteration is
Iter Root Eps1 #Var. Det. Energy #Davidson Time(s) 0 0 1.00e-04 154 -73.9576625954 17 0.00 1 0 1.00e-04 2672 -74.9629939144 36 0.04 2 0 1.00e-04 5380 -74.9783705312 7 0.09 3 0 1.00e-05 12260 -74.9784046222 4 0.23
The forth column prints the number of determinants in the iteration.
I am not sure what you mean by "unset" epsilon2Large. IF you send an example input file and tell us what you want to do we can help you with it.
Sandeep.
On Wed, Oct 2, 2024 at 7:46 PM Mauger Nastasia @.***> wrote:
Hello,
I am using DICE as a CASSCF solver with PySCF and would like some assistance.
-
I know that output.dat provides the most important determinant, but is there a way to print the complete list of determinants through the Python script I used to launch PySCF?
Additionally, I would like to print the number of determinants at each iteration. Is there a way to achieve this?
I'm also a bit confused about how to "unset" epsilon2Large, as it seems to be the default setting (from your pyscf input given in the manual). Could you clarify how I can modify or disable this parameter?
Thank you for your help
— Reply to this email directly, view it on GitHub https://github.com/sanshar/Dice/issues/24, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABVW4BHIXZL5NRU6LJPAPDZZSOWNAVCNFSM6AAAAABPIZ2RDWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU3DEOJUGY2TAMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hello,
Using these keywords:
casci = shci.SHCISCF(rhf, norb, nelec)
casci.verbose = 9
casci.wfnsym = 'A'
casci.fcisolver.mpiprefix = 'mpirun -np 4'
casci.fcisolver.stochastic = False
casci.fcisolver.dE = 1e-14
casci.fcisolver.sweep_iter = [0, 3]
casci.fcisolver.DoRDM = False
casci.fcisolver.sweep_epsilon = [1e-1, 1e-2]
e_shci = casci.mc1step()[0]
in PySCF leads to this automatically generated Dice input:
#variational
schedule
0 0.01
end
davidsonTol 5e-05
dE 1e-14
maxiter 10
fullrestart
#pt
deterministic
epsilon2 1e-07
epsilon2Large 1000
targetError 0.0001
sampleN 200
#misc
io
prefix .
As you might notice, although I want to perform a deterministic calculation, I still have epsilon2Large 1000
in the input.
Also, it is possible to access different energy components of this SHCI + PT object? It works when I am doing stochastic but not using the deterministic flavor. For some reason using make_rdm1
on the shci object does a core_dumped in the deterministic case.
Thank you!
epsilon2Large is a very large value and will not do any stochastic calculations. That is why it is set at a large value.
I am not sure I understand your second question? What do you mean by different energy components?
On Tue, Oct 22, 2024 at 7:56 PM Mauger Nastasia @.***> wrote:
Hello,
Using these keywords:
casci = shci.SHCISCF(rhf, norb, nelec) casci.verbose = 9 casci.wfnsym = 'A' casci.fcisolver.mpiprefix = 'mpirun -np 4' casci.fcisolver.stochastic = Falsecasci.fcisolver.dE = 1e-14 casci.fcisolver.sweep_iter = [0, 3] casci.fcisolver.DoRDM = False casci.fcisolver.sweep_epsilon = [1e-1, 1e-2] e_shci = casci.mc1step()[0]
in PySCF leads to this automatically generated Dice input:
variational
schedule 0 0.01 end davidsonTol 5e-05 dE 1e-14 maxiter 10 fullrestart
pt
deterministic epsilon2 1e-07 epsilon2Large 1000 targetError 0.0001 sampleN 200
misc
io prefix .
As you might notice, although I want to perform a deterministic calculation, I still have epsilon2Large 1000 in the input.
Also, does using make_rdm1() from PySCF make sense to access different energy components of this SHCI + PT object?
Thank you!
— Reply to this email directly, view it on GitHub https://github.com/sanshar/Dice/issues/24#issuecomment-2430640679, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABVW4DFK65I5PEP3VRCBQLZ4363HAVCNFSM6AAAAABPIZ2RDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZQGY2DANRXHE . You are receiving this because you commented.Message ID: @.***>
Hello,
This input:
#pt
deterministic
epsilon2 1e-07
epsilon2Large 1000
targetError 0.0001
sampleN 200
#misc
io
prefix .
DoOneRDM
DoSpinOneRDM
DoRDM
returns
Calculating 2-RDM
E(one-body) from 2RDM: -79.3809820285
E(two-body) from 2RDM: 26.0820512957
E from 2RDM: -39.8053959306
...
Deterministic PT calculation converged
PTEnergy: -39.8054550496
But I also would like to get the Kinetic, Potential and Ven energies
Best
Edit: If I am using stochastic, I can use make_rdm1 from Pyscf to get these energies. However, in deterministic, this is not the case anymore. Pyscf function returns core_dumped.
That is probably a bug. In reality the variational RDM is very reliable but the PT RDM is less reliable. But either way it is very easy to get the different components. You can obtain the nuclear, and kinetic energy integrals separately from pyscf in mo basis and contract with the 1-RDM that Dice prints to get nuclear and kinetic energy. For the 2-electron energy you will have to contract the two electron integrals with the 2-RDM.
Let me know if this helps.
On Tue, Oct 22, 2024 at 9:05 PM Mauger Nastasia @.***> wrote:
Edit: If I am using stochastic, I can use make_rdm1 from Pyscf to get these energies. However, in deterministic, this is not the case anymore. Pyscf function returns core_dumped.
— Reply to this email directly, view it on GitHub https://github.com/sanshar/Dice/issues/24#issuecomment-2430745255, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABVW4ABTNCXTLPWCOOCTK3Z44G63AVCNFSM6AAAAABPIZ2RDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZQG42DKMRVGU . You are receiving this because you commented.Message ID: @.***>
Hello,,
I am a bit confused by your answer because, as I previously mentioned, the method you suggested works fine with the stochastic flavor of DICE. However, it fails for the deterministic version (casci.fcisolver.stochastic = False
) , resulting in a core dump.
Here is my script related to DICE:
from pyscf.shciscf import shci
norb = 33
nelec = 8
casci = shci.SHCISCF(rhf, norb, nelec)
casci.verbose = 9
casci.wfnsym = 'A'
casci.fcisolver.mpiprefix = 'mpirun -np 24'
casci.fcisolver.stochastic = True
casci.fcisolver.nPTiter = 0
casci.fcisolver.sweep_iter = [0, 5]
casci.fcisolver.DoRDM = True
casci.fcisolver.sweep_epsilon = [1e-1, 1e-5]
e_shci = casci.mc1step()[0]
# Extract energies from the MCSCF object
e_tot = casci.e_tot # Total energy
e_nuc = casci.energy_nuc() # Nuclear repulsion energy
e_cas = casci.e_cas
e_core = e_tot - e_nuc - (e_cas - e_nuc)
# Calculate CASSCF kinetic and potential energies
casci_rdm1 = casci.make_rdm1() # Density matrix
casci_kinetic_energy = np.einsum('ij,ji->', mol.intor('int1e_kin'), casci_rdm1)
casci_potential_energy = e_tot - casci_kinetic_energy
casci_virial_ratio = casci_potential_energy / casci_kinetic_energy
# Calculate the one-electron energy contribution
h1 = mol.intor('int1e_kin') + mol.intor('int1e_nuc')
casci_one_electron_energy = np.einsum('pq,qp->', h1, casci_rdm1)
# Compute the nucleus-electron potential energy using the CASCI wavefunction
nucleus_electron_potential_energy = np.einsum('ij,ji->', mol.intor('int1e_nuc'), casci_rdm1)
# Print detailed energy components for CASSCF
print("--------------------------------------------------------")
print(" CASCI Energies Component")
print("--------------------------------------------------------")
print(f"Total Energy : {e_tot:.14f} Eh\n")
print("Components:")
print(f"Nuclear Repulsion : {e_nuc:.14f} Eh")
print(f"One Electron Energy : {casci_one_electron_energy:.14f} Eh")
print(f"Core Energy : {e_core:.14f} Eh\n")
print(f"Nucleus-Electron Potential Energy: {nucleus_electron_potential_energy:.14f} Eh\n")
print(f"CASCI Kinetic Energy : {casci_kinetic_energy:.14f} Eh")
print(f"CASCI Potential Energy: {casci_potential_energy:.14f} Eh")
print(f"CASCI Virial Ratio : {casci_virial_ratio:.14f}")
Am I missing something ?
Best
Hello,
I wonder if there might be a bug in the deterministic case because the following code:
norb = 8
nelec = 8
casci = shci.SHCISCF(rhf, norb, nelec)
casci.verbose = 9
casci.wfnsym = 'A'
casci.fcisolver.mpiprefix = 'mpirun -np 4'
casci.fcisolver.stochastic = False
casci.fcisolver.nPTiter = 0
casci.fcisolver.sweep_iter = [0, 3]
casci.fcisolver.DoRDM = False
casci.fcisolver.sweep_epsilon = [1e-1, 1e-2]
casci.fcisolver.epsilon2 = 1e-8
casci.fcisolver.nPTiter = 0
e_shci = casci.mc1step()[0]
always crashes, even though I'm using the STO-3G basis set.
The issue is that Dice converges correctly, but PySCF crashes with a segmentation fault
error. As a result, I can't use this code snippet (https://github.com/sanshar/Dice/issues/24#issuecomment-2430980053) to extract more information.
Best
Hello,
I am using DICE as a CASSCF solver with PySCF and would like some assistance.
I know that output.dat provides the most important determinant, but is there a way to print the complete list of determinants through the Python script I used to launch PySCF?
Additionally, I would like to print the number of determinants at each iteration. Is there a way to achieve this?
I'm also a bit confused about how to "unset" epsilon2Large, as it seems to be the default setting (from your pyscf input given in the manual). Could you clarify how I can modify or disable this parameter?
Thank you for your help