CFEL-CMI / richmol

Richmol is for variational simulations of molecular nuclear motion dynamics in fields
https://www.controlled-molecule-imaging.org/research/software/
Other
7 stars 1 forks source link

Problem with tdse.update() #21

Closed samoplesnik closed 3 years ago

samoplesnik commented 3 years ago

I am running Richmol on Google Collab. When I try to run tdse_101.ipynb i get the following error:


NameError Traceback (most recent call last)

in () 35 36 # update vector ---> 37 vecs, t_ = tdse.update(H+h0, vecs=vecs, matvec_lib='scipy') 38 #vecs, t_ = tdse.update(H, H0=h0, vecs=vecs, matvec_lib='scipy') # for split-operator approach 39 1 frames /usr/local/lib/python3.7/dist-packages/richmol/tdse.py in update(self, H, vecs, **kwargs) 418 vecs2 = np.empty(vecs.shape, dtype=vecs.dtype) 419 for ind, vec in enumerate(vecs): --> 420 vecs2[ind] = _expv_lanczos( 421 vec, exp_fac, lambda v : cartensvec(v), tol=tol 422 ) NameError: name '_expv_lanczos' is not defined ----------------------------------------------------------------------------------------------------------------------------- When I try to call tdse.update the different way and use split-operator approach I get the following error: ----------------------------------------------------------------------------------------------------------------------------- AssertionError Traceback (most recent call last) in () 36 # update vector 37 #vecs, t_ = tdse.update(H+h0, vecs=vecs, matvec_lib='scipy') ---> 38 vecs, t_ = tdse.update(H, H0=h0, vecs=vecs, matvec_lib='scipy') # for split-operator approach 39 40 # expectation value of cos^2(theta) 1 frames /usr/local/lib/python3.7/dist-packages/richmol/tdse.py in update(self, H, vecs, **kwargs) 318 f"field-free Hamiltonian `H0` has bad type: " \ 319 + f"'{type(kwargs['H0'])}', " \ --> 320 + f"(must be '{richmol.field.CarTens}')" 321 H0 = kwargs['H0'] 322 else: AssertionError: field-free Hamiltonian `H0` has bad type: '', (must be '') ----------------------------------------------------------------------------------------------------------------------------- Here it feels like the tdse.update() function doesn't recognise the LabTensor object as belonging to CarTens and the assertion gives error. The same error comes up in other time evolution codes where h0 is defined as LabTensor...I tried ocs_mixed_field.py ; ocs_alignment.py
saribalc commented 3 years ago

Hi @samoplesnik , thank you very much for your feedback!

The two commits above should resolve this issue. With them I am able to successfully run the mentioned notebook and examples, reproducing plausible results again.