Open xiaowei-xie2 opened 6 months ago
You declare that the scale
parameter should be a float
:
def forward(self, coordinates: torch.Tensor, cell: torch.Tensor, scale: float, RcNL: float = 10.0):
But when OpenMM calls your module, it passes all the arguments as Tensors, leading to the exception
openmm.OpenMMException: forward() Expected a value of type 'float' for argument 'scale' but instead found type 'Tensor'.
If you change your declaration to scale: torch.Tensor
, it should work.
That worked, thank you! A follow-up question: can I get the derivative w.r.t. that global parameter along the MD trajectory?
No, but that would be a reasonable feature to add. Is that something you would find useful?
Yes, I think that would be super helpful for any FEP type calculations with ML force fields! Do you know any workarounds at the moment? If I can write out the derivative expression myself, what would be a way to save that value at each MD frame?
I created a feature request for it (#141). I'll try to do it soon. I don't think it should be difficult.
Thank you so much!
The implementation is at #143. If you care to try it out, please let us know whether it works for you.
Wow, thank you! Do I need to build from source from your branch to test it out?
Yes, if that's not too difficult. Otherwise you'll need to wait for the next release.
No problem, I will give it a try soon and let you know!
Hi,
I was trying to add a global parameter to my torchForce, but I could not figure out how to make it work along with the PBC. Could you help me have a look?
Here is the structure of my torchForce class:
Then when I try to load the model with
and try to run a MD with it, I get the following error:
Thank you so much!