modify poisson inv

This commit is contained in:
Dario Coscia
2025-03-14 16:16:39 +01:00
committed by Nicola Demo
parent f9881a79b5
commit 0fcb78bc51

View File

@@ -1,8 +1,10 @@
"""Formulation of the inverse Poisson problem in a square domain.""" """Formulation of the inverse Poisson problem in a square domain."""
import os import requests
import torch import torch
from io import BytesIO
from ... import Condition from ... import Condition
from ... import LabelTensor
from ...operator import laplacian from ...operator import laplacian
from ...domain import CartesianDomain from ...domain import CartesianDomain
from ...equation import Equation, FixedValue from ...equation import Equation, FixedValue
@@ -27,21 +29,27 @@ def laplace_equation(input_, output_, params_):
return delta_u - force_term return delta_u - force_term
# Absolute path to the data directory # URL of the file
data_dir = os.path.abspath( url = "https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pts_0.5_0.5"
os.path.join( # Download the file
os.path.dirname(__file__), "../../../tutorials/tutorial7/data/" response = requests.get(url)
) response.raise_for_status()
file_like_object = BytesIO(response.content)
# Set the data
input_data = LabelTensor(
torch.load(file_like_object, weights_only=False).tensor.detach(),
["x", "y", "mu1", "mu2"],
) )
# Load input data # URL of the file
input_data = torch.load( url = "https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pinn_solution_0.5_0.5"
f=os.path.join(data_dir, "pts_0.5_0.5"), weights_only=False # Download the file
).extract(["x", "y"]) response = requests.get(url)
response.raise_for_status()
# Load output data file_like_object = BytesIO(response.content)
output_data = torch.load( # Set the data
f=os.path.join(data_dir, "pinn_solution_0.5_0.5"), weights_only=False output_data = LabelTensor(
torch.load(file_like_object, weights_only=False).tensor.detach(), ["u"]
) )