Spaces:
Running
Running
Update TenCirChem/mcp_output/mcp_plugin/mcp_service.py
Browse files
TenCirChem/mcp_output/mcp_plugin/mcp_service.py
CHANGED
|
@@ -78,7 +78,7 @@ def run_ucc(atom_list: list, basis: str, ansatz: str) -> dict:
|
|
| 78 |
except Exception as e:
|
| 79 |
return {"success": False, "error": str(e)}
|
| 80 |
|
| 81 |
-
@mcp.tool(name="simulate_time_evolution", description="
|
| 82 |
def simulate_time_evolution(atom_list: list, basis: str, time: float, steps: int) -> dict:
|
| 83 |
"""
|
| 84 |
Simulate time evolution for a given molecule.
|
|
@@ -96,17 +96,17 @@ def simulate_time_evolution(atom_list: list, basis: str, time: float, steps: int
|
|
| 96 |
# Create PySCF molecule object
|
| 97 |
mol = M(atom=atom_list, basis=basis)
|
| 98 |
mol.build()
|
| 99 |
-
# Build HF and Hamiltonian (sparse)
|
| 100 |
from pyscf.scf import RHF
|
| 101 |
hf = RHF(mol)
|
| 102 |
hf.kernel()
|
| 103 |
h_sparse = get_h_from_hf(hf, hcb=False, htype="sparse")
|
| 104 |
h = h_sparse.toarray() if sp.issparse(h_sparse) else np.array(h_sparse)
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
| 106 |
dt = float(time) / max(1, int(steps))
|
| 107 |
-
# initial state |0...0>
|
| 108 |
-
psi = np.zeros(dim, dtype=np.complex128)
|
| 109 |
-
psi[0] = 1.0
|
| 110 |
times = [0.0]
|
| 111 |
energies = [float(np.real(np.vdot(psi, h @ psi)))]
|
| 112 |
# single-step propagator
|
|
|
|
| 78 |
except Exception as e:
|
| 79 |
return {"success": False, "error": str(e)}
|
| 80 |
|
| 81 |
+
@mcp.tool(name="simulate_time_evolution", description="Scheme A: evolve from UCCSD ground state under the electronic Hamiltonian.")
|
| 82 |
def simulate_time_evolution(atom_list: list, basis: str, time: float, steps: int) -> dict:
|
| 83 |
"""
|
| 84 |
Simulate time evolution for a given molecule.
|
|
|
|
| 96 |
# Create PySCF molecule object
|
| 97 |
mol = M(atom=atom_list, basis=basis)
|
| 98 |
mol.build()
|
| 99 |
+
# Build HF and Hamiltonian (sparse)
|
| 100 |
from pyscf.scf import RHF
|
| 101 |
hf = RHF(mol)
|
| 102 |
hf.kernel()
|
| 103 |
h_sparse = get_h_from_hf(hf, hcb=False, htype="sparse")
|
| 104 |
h = h_sparse.toarray() if sp.issparse(h_sparse) else np.array(h_sparse)
|
| 105 |
+
# Use UCCSD ground state as initial state
|
| 106 |
+
ucc = UCCSD(mol)
|
| 107 |
+
_ = ucc.kernel()
|
| 108 |
+
psi = np.array(ucc.statevector(), dtype=np.complex128)
|
| 109 |
dt = float(time) / max(1, int(steps))
|
|
|
|
|
|
|
|
|
|
| 110 |
times = [0.0]
|
| 111 |
energies = [float(np.real(np.vdot(psi, h @ psi)))]
|
| 112 |
# single-step propagator
|