mathLab / PINA

Physics-Informed Neural networks for Advanced modeling
https://mathlab.github.io/PINA/
MIT License
378 stars 65 forks source link

Same set of parameters for different locations #355

Open luAndre00 opened 2 weeks ago

luAndre00 commented 2 weeks ago

Hi! When I do the discretisation of a problem in general for every location the discretisation is independent from the other locations one's. Sometimes it could be reasonable to have the same set of points for different location. For example in a parametric problem I would like to have the same set of parameters for the domain of the problem and for the boundary conditions. I tested some ways of getting this but I could not do it, I wonder if there is an efficient way of doing this, or if there is not, maybe it could a new feature to be inserted.

The only solution to this that i could find is setting the same seed before every discretization, but it is quite "heavy" to see:

torch.manual_seed(seed); opc.discretise_domain(n=50, mode=args.sampling, variables=['mu1', 'mu2'], locations=['D']) torch.manual_seed(seed); opc.discretise_domain(n=50, mode=args.sampling, variables=['mu1', 'mu2'], locations=['gamma1']) torch.manual_seed(seed); opc.discretise_domain(n=50, mode=args.sampling, variables=['mu1', 'mu2'], locations=['gamma2']) torch.manual_seed(seed); opc.discretise_domain(n=50, mode=args.sampling, variables=['mu1', 'mu2'], locations=['gamma3']) torch.manual_seed(seed); opc.discretise_domain(n=50, mode=args.sampling, variables=['mu1', 'mu2'], locations=['gamma4'])

Thank you for your attention!

dario-coscia commented 2 weeks ago

Hi @luAndre00 ! Yes, I agree with you that sometimes it could be reasonable to have the same set of points for different locations, I think you can achieve this easily if your use mode='grid' or mode='chebyshev' in discretise_domain.

The situation is different for random points, and there isn't an easier way than the one you found. The problem is that we iterate over the locations to sample, and if we fix the seed before the for loop we will not obtain the same samples (see here)...