lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.75k stars 755 forks source link

Can deepxde be dimensionless? #1546

Open staarr opened 1 year ago

staarr commented 1 year ago

Hi @lululxvi , In some special cases, the input and output need to be scaled to a certain range. Take the following example: def pde(x,y): c_star=4.0 r_star=20.0 t_star=30.0 yd = y/c_star rd = x[:,0]/r_star td = x[:,1]/t_star dy_t = dde.grad.jacobian(yd,td,i=0,j=0) dy_rr = dde.grad.hessian(yd,rd,i=0,j=0) return dy_rr-dy_t But there will be an error running, how to solve it?

jdellag commented 1 year ago

FWIW, I never have division anywhere inside my PDE function. In the past it has resulted in nan values in my losses and just created a lot of numerical instability. Was it a hassle to reformulate everything in order to handle this? Yes, but it was the only thing to make the program run.

haison19952013 commented 1 year ago

Let's use some mathematics to overcome this problem. For example, you can use the chain rule to compute dy'/dt' as followings:

So the final code should be: dy_prime_dt_prime = dde.grad.jacobian(y,t,i=0,j=0) * t_star/c_star