NeuroDiffGym / neurodiffeq

A library for solving differential equations using neural networks based on PyTorch, used by multiple research groups around the world, including at Harvard IACS.
http://pypi.org/project/neurodiffeq/
MIT License
702 stars 90 forks source link

Solving ODEs - Skipping correct reparametrization #64

Closed hargun3045 closed 4 years ago

hargun3045 commented 4 years ago

Hi team,

I imagine there is an issue while solving ODEs with initial x_0_prime=0.

It appears that in this case, the correct reparametrization is skipped and we suspect the below code from ode.py maybe the cause.

        if self.x_0_prime:
            return self.x_0 + (t-self.t_0)*self.x_0_prime + ( (1-torch.exp(-t+self.t_0))**2 )*x
        else:
            return self.x_0 + (1-torch.exp(-t+self.t_0))*x

If self.x_0_prime is 0, then the if block is skipped, giving the second reparametrization.

shuheng-liu commented 4 years ago

That's right, we should do this

if self.x_0_prime is not None:

I'm pushing a fix right now.