Skip to content

Conversation

@dario-coscia
Copy link
Collaborator

@dario-coscia dario-coscia commented Mar 15, 2024

New Added Solvers

  • GPINN solver class gradient enhanced pinn paper link
  • CausalPINN solver class causal pinn paper link
  • SAPINN solver class self adaptive pinn paper link
  • CompetitivePINN solver class self adaptive pinn paper link
  • ReducedOrderModel solver class paper link

Modifying existing solvers

  • GAROM, SupervisedSolver, SolverInterface adding the on_train_start method for checks on dataloader
  • SupervisedSolver adds a loss_data method which defines the computation of the loss function. User can inherit from this class to create data-driven solvers (e.g. ReducedOrderModelSolver)

Miscellaneous
Adding tests and modifying documentation. Now each solver is documented and explained in its mathematical formulation.

@dario-coscia dario-coscia mentioned this pull request Apr 3, 2024
@AleDinve AleDinve mentioned this pull request Apr 5, 2024
@dario-coscia dario-coscia changed the title PINN variants addition PINN variants addition and Solvers Update Apr 30, 2024
Dario Coscia and others added 13 commits April 30, 2024 19:07
* causal pinn
* ref update/ codacy
* Create a `compute_residual` attribute for `PINNInterface`
* Adding in PINNInterface a variable to track the current condition during training
* Modify GPINN,PINN,CausalPINN to match changes in PINNInterface
* competitive pinns
* fixing after rebase/ fix loss
* fixing final issues

---------

Co-authored-by: Dario Coscia <[email protected]>
* Create sapinn.py
* Final sapinn
* Update doc
* Modify tests SAPINN
@dario-coscia dario-coscia marked this pull request as ready for review April 30, 2024 17:14
@dario-coscia dario-coscia requested review from annaivagnes, guglielmopadula and ndem0 and removed request for annaivagnes April 30, 2024 17:14
@dario-coscia
Copy link
Collaborator Author

Hi @ndem0 @guglielmopadula 👋🏻

Lately, with @annaivagnes @valc89 and myself, we have been working to modify existing bugs in PINA solvers and create new solvers. Here I tried to summarize the most relevant feature of this pull request.

Let us know if you are satisfied with the changes, we could also think of adding a comparative tutorial for physics-informed based solvers if interested! Thanks🚀😃

@dario-coscia dario-coscia self-assigned this Apr 30, 2024
@dario-coscia dario-coscia added the pr-to-review Label for PR that are ready to been reviewed label Apr 30, 2024
@guglielmopadula
Copy link
Member

Hi! Exceptional work!
I have only three observations:

  1. From the SAPINN paper, it seems to me that there is a different weight for every point of every condition. In your implementation however it seems that there is only one weight for every condition, so points belonging to the same condition have the same weight. Is this correct?
  2. I personally don't like a long sequence of commented lines of code for todos (talking about the tests now), maybe we can remove the commented lines and add a new issue/discussion.
  3. I can't find the ReducedOrderSolver in the modifications. I am pretty sure however that it was there when I checked for the first time. I am simply blind because of the late hour or it has been removed?
    Thank you.

@dario-coscia
Copy link
Collaborator Author

dario-coscia commented May 4, 2024

Hi! Exceptional work! I have only three observations:

  1. From the SAPINN paper, it seems to me that there is a different weight for every point of every condition. In your implementation however it seems that there is only one weight for every condition, so points belonging to the same condition have the same weight. Is this correct?
  2. I personally don't like a long sequence of commented lines of code for todos (talking about the tests now), maybe we can remove the commented lines and add a new issue/discussion.
  3. I can't find the ReducedOrderSolver in the modifications. I am pretty sure however that it was there when I checked for the first time. I am simply blind because of the late hour or it has been removed?
    Thank you.

Thanks for spotting point (3), I added ROM solver (idk what happened). Regarding point 2 we left it commented as it was, once GPU tests will be activated on Github we will remove the comments. For point one we do follow the convention that we have one point for each residual point, we do this in on_train_start

    def on_train_start(self):
        """
        This method is called at the start of the training for setting
        the self adaptive weights as parameters of the mask model.

        :return: Whatever is returned by the parent
            method ``on_train_start``.
        :rtype: Any
        """
        device = torch.device(
            self.trainer._accelerator_connector._accelerator_flag
        )
        for condition_name, tensor in self.problem.input_pts.items():
            self.weights_dict.torchmodel[condition_name].sa_weights.data = torch.rand(
                (tensor.shape[0], 1),
                device = device
            )

Of course, if someone changes the point during training (but why one should do it with SAPINN?) by a callback everything breaks (so maybe we can think about something smarter @valc89 ?) A warning in the documentation its a good start anyway.

@dario-coscia dario-coscia mentioned this pull request May 4, 2024
Copy link
Member

@guglielmopadula guglielmopadula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy complains. Apart from that the code is fine for me!

@ndem0
Copy link
Member

ndem0 commented May 6, 2024

I'm trying to fix the local imports and we're done.

@ndem0 ndem0 self-assigned this May 6, 2024
@ndem0 ndem0 added pr-to-fix Label for PR that needs modification and removed pr-to-review Label for PR that are ready to been reviewed labels May 6, 2024
@dario-coscia
Copy link
Collaborator Author

@ndem0 Can we merge?

@dario-coscia dario-coscia removed the pr-to-fix Label for PR that needs modification label May 10, 2024
@dario-coscia dario-coscia merged commit e0429bb into master May 10, 2024
@ndem0 ndem0 deleted the new_pinns branch May 11, 2024 09:00
ndem0 added a commit that referenced this pull request Sep 9, 2024
* gpinn/basepinn new classes, pinn restructure
* codacy fix gpinn/basepinn/pinn
* inverse problem fix
* Causal PINN (#267)
* fix GPU training in inverse problem (#283)
* Create a `compute_residual` attribute for `PINNInterface`
* Modify dataloading in solvers (#286)
* Modify PINNInterface by removing _loss_phys, _loss_data
* Adding in PINNInterface a variable to track the current condition during training
* Modify GPINN,PINN,CausalPINN to match changes in PINNInterface
* Competitive Pinn Addition (#288)
* fixing after rebase/ fix loss
* fixing final issues

---------

Co-authored-by: Dario Coscia <[email protected]>

* Modify min max formulation to max min for paper consistency
* Adding SAPINN solver (#291)
* rom solver
* fix import

---------

Co-authored-by: Dario Coscia <[email protected]>
Co-authored-by: Anna Ivagnes <[email protected]>
Co-authored-by: valc89 <[email protected]>
Co-authored-by: Monthly Tag bot <[email protected]>
Co-authored-by: Nicola Demo <[email protected]>
ndem0 added a commit that referenced this pull request Sep 9, 2024
* gpinn/basepinn new classes, pinn restructure
* codacy fix gpinn/basepinn/pinn
* inverse problem fix
* Causal PINN (#267)
* fix GPU training in inverse problem (#283)
* Create a `compute_residual` attribute for `PINNInterface`
* Modify dataloading in solvers (#286)
* Modify PINNInterface by removing _loss_phys, _loss_data
* Adding in PINNInterface a variable to track the current condition during training
* Modify GPINN,PINN,CausalPINN to match changes in PINNInterface
* Competitive Pinn Addition (#288)
* fixing after rebase/ fix loss
* fixing final issues

---------

Co-authored-by: Dario Coscia <[email protected]>

* Modify min max formulation to max min for paper consistency
* Adding SAPINN solver (#291)
* rom solver
* fix import

---------

Co-authored-by: Dario Coscia <[email protected]>
Co-authored-by: Anna Ivagnes <[email protected]>
Co-authored-by: valc89 <[email protected]>
Co-authored-by: Monthly Tag bot <[email protected]>
Co-authored-by: Nicola Demo <[email protected]>
dario-coscia added a commit that referenced this pull request Mar 12, 2025
* gpinn/basepinn new classes, pinn restructure
* codacy fix gpinn/basepinn/pinn
* inverse problem fix
* Causal PINN (#267)
* fix GPU training in inverse problem (#283)
* Create a `compute_residual` attribute for `PINNInterface`
* Modify dataloading in solvers (#286)
* Modify PINNInterface by removing _loss_phys, _loss_data
* Adding in PINNInterface a variable to track the current condition during training
* Modify GPINN,PINN,CausalPINN to match changes in PINNInterface
* Competitive Pinn Addition (#288)
* fixing after rebase/ fix loss
* fixing final issues

---------

Co-authored-by: Dario Coscia <[email protected]>

* Modify min max formulation to max min for paper consistency
* Adding SAPINN solver (#291)
* rom solver
* fix import

---------

Co-authored-by: Dario Coscia <[email protected]>
Co-authored-by: Anna Ivagnes <[email protected]>
Co-authored-by: valc89 <[email protected]>
Co-authored-by: Monthly Tag bot <[email protected]>
Co-authored-by: Nicola Demo <[email protected]>
dario-coscia added a commit that referenced this pull request Apr 17, 2025
* gpinn/basepinn new classes, pinn restructure
* codacy fix gpinn/basepinn/pinn
* inverse problem fix
* Causal PINN (#267)
* fix GPU training in inverse problem (#283)
* Create a `compute_residual` attribute for `PINNInterface`
* Modify dataloading in solvers (#286)
* Modify PINNInterface by removing _loss_phys, _loss_data
* Adding in PINNInterface a variable to track the current condition during training
* Modify GPINN,PINN,CausalPINN to match changes in PINNInterface
* Competitive Pinn Addition (#288)
* fixing after rebase/ fix loss
* fixing final issues

---------

Co-authored-by: Dario Coscia <[email protected]>

* Modify min max formulation to max min for paper consistency
* Adding SAPINN solver (#291)
* rom solver
* fix import

---------

Co-authored-by: Dario Coscia <[email protected]>
Co-authored-by: Anna Ivagnes <[email protected]>
Co-authored-by: valc89 <[email protected]>
Co-authored-by: Monthly Tag bot <[email protected]>
Co-authored-by: Nicola Demo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants