Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Condition takes only the following keyword BUG #90

Closed
LoveFrootLoops opened this issue May 5, 2023 · 14 comments
Closed

Condition takes only the following keyword BUG #90

LoveFrootLoops opened this issue May 5, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@LoveFrootLoops
Copy link

LoveFrootLoops commented May 5, 2023

Upon running the Tutorial 1 Code (copy-pasted), an error message appeared instantly:

Traceback (most recent call last):
File "C:\Users\PycharmProjects\pythonProject\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3508, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
runfile('C:\Users\PycharmProjects\pythonProject\test.py', wdir='C:\Users\PycharmProjects\pythonProject')
File "C:\Program Files\JetBrains\PyCharm 2023.1.1\plugins\python\helpers\pydev_pydev_bundle\pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2023.1.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\Users\PycharmProjects\pythonProject\test.py", line 82, in
class SimpleODE(SpatialProblem):
File "C:\Users\PycharmProjects\pythonProject\test.py", line 110, in SimpleODE
'x0': Condition(Span({'x': 0.}), initial_condition),
File "C:\Users\PycharmProjects\pythonProject\venv\lib\site-packages\pina\condition.py", line 69, in init
raise ValueError('Condition takes only the following keyword arguments: {input_points, output_points, location, function, data_weight}.')
ValueError: Condition takes only the following keyword arguments: {input_points, output_points, location, function, data_weight}.

@LoveFrootLoops LoveFrootLoops added the bug Something isn't working label May 5, 2023
@ndem0
Copy link
Member

ndem0 commented May 5, 2023

Dear @LoveFrootLoops, thanks for reporting!
Yes, tutorials need to be updated to the current version of the package (we changed some methods in the last commits). Hope to fix it asap, I'll notify here when we'll finish!

@dario-coscia
Copy link
Collaborator

@ndem0 I am on it to change the tutorial

@dario-coscia dario-coscia mentioned this issue May 5, 2023
@dario-coscia
Copy link
Collaborator

👋🏻 @LoveFrootLoops Thank you for the report.

Recently we changed the class Condition, which now takes only the following keyword arguments: input_points, output_points, location, function, data_weight. Unfortunately the documentation is not updated on the website yet, as we do it automatically once a month. Anyway you can look at the the class docstrings for reference

Now the tutorials should all work, hope it helps.

@dario-coscia
Copy link
Collaborator

@ndem0 If for you it is ok, it can be merged

@LoveFrootLoops
Copy link
Author

LoveFrootLoops commented May 5, 2023

Thanks for the fast response! @dario-coscia Is it still possible to include multiple functions in a condition, such as "function=[func1, func2]"?

@dario-coscia
Copy link
Collaborator

dario-coscia commented May 6, 2023

Thanks for the fast response! @dario-coscia Is it still possible to include multiple functions in a condition, such as "function=[func1, func2]"?

No, it is not possible. The kwarg function must be a callable function. Also I am wondering, why do you need it? Generally, in a PINN learning approach you want to minimize the residual obtained in a specific location between the function of interest and the expected output. Yes, the function can be scalar/ vectorial and multivariate, but it is always one.

Tell me if it helps. For reference I suggest you Scientific Machine Learning through Physics-Informed Neural Networks: Where we are and What's next, which is a nice and concise introduction to PINNs and Neural Operators.

@LoveFrootLoops
Copy link
Author

Thanks for the fast response! @dario-coscia Is it still possible to include multiple functions in a condition, such as "function=[func1, func2]"?

No, it is not possible. The kwarg function must be a callable function. Also I am wondering, why do you need it? Generally, in a PINN learning approach you want to minimize the residual obtained in a specific location between the function of interest and the expected output. Yes, the function can be scalar/ vectorial and multivariate, but it is always one.

Tell me if it helps. For reference I suggest you Scientific Machine Learning through Physics-Informed Neural Networks: Where we are and What's next, which is a nice and concise introduction to PINNs and Neural Operators.

Good morning ;)
If I have multiple cost functions for the same domain/location I would now have to define multiple conditions. That’s why I asked if it possible to define multiple functions for the same domain without repetition.

@dario-coscia
Copy link
Collaborator

@LoveFrootLoops can you send me the snippet of code you are using? I don't understand why you should minimize the same function on the same location.

@LoveFrootLoops
Copy link
Author

Let’s assume I have two PDEs which I want to solve for the same function “u” ont he same domain Omega, let’s call them PDE1 and PDE2. Then I would have to do the following:

conditions = {
'Omega1' Condition(location=Span({'x': [0, 1], 'y': [0, 1]}), function=PDE1),
'Omega2' Condition(location=Span({'x': [0, 1], 'y': [0, 1]}), function=PDE2)
}

instead of:

conditions = {
'Omega' Condition(location=Span({'x': [0, 1], 'y': [0, 1]}), function=[PDE1,PDE2])
}

@dario-coscia
Copy link
Collaborator

I dont really understand. I have never seen that in the same domain more conditions are applied. Can you send me the reference of equations you are dealing with?

If it's something useful we can think to make a pull request to make it in the next release.

@LoveFrootLoops
Copy link
Author

LoveFrootLoops commented May 6, 2023

Although my demonstration involved PDEs, I want to clarify that my point applies to a broader range of scenarios. For instance, restrictions such as the positivity of 'u' over the domain Omega can be effectively addressed with this approach. However, at present, I must define a new condition for each constraint, even if it pertains to the same domain.

Additionally, if I understand correctly, PINA allows for minimizing 'u' given specific input and output data. However, how about handle input and output data that correspond to derivatives of the function 'u.'
In mechanics, there is another approach to consider where multiple functions correspond to each other through a mapping but need to solve different PDEs over the same domain Omega. For instance, the functions "strain," "stress," and "displacement" may need to be determined. Stresses are subject to the PDE 'div(stress)=f,' while strains must satisfy the PDE 'grad(displacement)=strain.' These two functions, strains and stresses, are related through a mapping 'C(strain)=stress,' which may be quite complex.

In this scenario, three conditions would be required over the same domain. It's worth noting that this approach has applications in various fields, including engineering and physics.

@dario-coscia
Copy link
Collaborator

Although my demonstration involved PDEs, I want to clarify that my point applies to a broader range of scenarios. For instance, restrictions such as the positivity of 'u' over the domain Omega can be effectively addressed with this approach. However, at present, I must define a new condition for each constraint, even if it pertains to the same domain.

Additionally, if I understand correctly, PINA allows for minimizing 'u' given specific input and output data. However, how about handle input and output data that correspond to derivatives of the function 'u.'

In mechanics, there is another approach to consider where multiple functions correspond to each other through a mapping but need to solve different PDEs over the same domain Omega. For instance, the functions "strain," "stress," and "displacement" may need to be determined. Stresses are subject to the PDE 'div(stress)=f,' while strains must satisfy the PDE 'grad(displacement)=strain.' These two functions, strains and stresses, are related through a mapping 'C(strain)=stress,' which may be quite complex.

In this scenario, three conditions would be required over the same domain. It's worth noting that this approach has applications in various fields, including engineering and physics.

Thank you for the reply. Indeed you are right, it might be useful to insert this possibility. I have opened a new issue #92 for inserting this possibility. Tell me if you are interested working on it.

I will close this issue once the tutorials are merged by @ndem0. To follow the discussion please use #92

@LoveFrootLoops
Copy link
Author

Although my demonstration involved PDEs, I want to clarify that my point applies to a broader range of scenarios. For instance, restrictions such as the positivity of 'u' over the domain Omega can be effectively addressed with this approach. However, at present, I must define a new condition for each constraint, even if it pertains to the same domain.
Additionally, if I understand correctly, PINA allows for minimizing 'u' given specific input and output data. However, how about handle input and output data that correspond to derivatives of the function 'u.'
In mechanics, there is another approach to consider where multiple functions correspond to each other through a mapping but need to solve different PDEs over the same domain Omega. For instance, the functions "strain," "stress," and "displacement" may need to be determined. Stresses are subject to the PDE 'div(stress)=f,' while strains must satisfy the PDE 'grad(displacement)=strain.' These two functions, strains and stresses, are related through a mapping 'C(strain)=stress,' which may be quite complex.
In this scenario, three conditions would be required over the same domain. It's worth noting that this approach has applications in various fields, including engineering and physics.

Thank you for the reply. Indeed you are right, it might be useful to insert this possibility. I have opened a new issue #92 for inserting this possibility. Tell me if you are interested working on it.

I will close this issue once the tutorials are merged by @ndem0. To follow the discussion please use #92

I am new to this GitHub Game but yes sure, I could work on it.

@dario-coscia
Copy link
Collaborator

@ndem0 this issue can be close, since it is related to the tutorials merged in 9de4e51

@ndem0 ndem0 closed this as completed May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants