CartesianDomain#
- class CartesianDomain(cartesian_dict)[source]
Bases:
Location
PINA implementation of Hypercube domain.
- Parameters:
cartesian_dict (dict) – A dictionary with dict-key a string representing the input variables for the pinn, and dict-value a list with the domain extrema.
- Example:
>>> spatial_domain = CartesianDomain({'x': [0, 1], 'y': [0, 1]})
- property variables
Spatial variables.
- update(new_domain)[source]
Adding new dimensions on the
CartesianDomain
- Parameters:
new_domain (CartesianDomain) – A new
CartesianDomain
object to merge- Example:
>>> spatial_domain = CartesianDomain({'x': [0, 1], 'y': [0, 1]}) >>> spatial_domain.variables ['x', 'y'] >>> spatial_domain_2 = CartesianDomain({'z': [3, 4], 'w': [0, 1]}) >>> spatial_domain.update(spatial_domain_2) >>> spatial_domain.variables ['x', 'y', 'z', 'w']
- sample(n, mode='random', variables='all')[source]
Sample routine.
- Parameters:
n (int) – Number of points to sample, see Note below for reference.
mode (str) – Mode for sampling, defaults to
random
. Available modes include: random sampling,random
; latin hypercube sampling,latin
orlh
; chebyshev sampling,chebyshev
; grid samplinggrid
.variables (str | list[str]) – pinn variable to be sampled, defaults to
all
.
- Returns:
Returns
LabelTensor
of n sampled points.- Return type:
Note
The total number of points sampled in case of multiple variables is not
n
, and it depends on the chosenmode
. Ifmode
is ‘grid’ orchebyshev
, the points are sampled independentely across the variables and the results crossed together, i.e. the final number of points isn
to the power of the number of variables. If ‘mode’ is ‘random’,lh
orlatin
, the variables are sampled all together, and the final number of pointsWarning
The extrema values of Span are always sampled only for
grid
mode.- Example:
>>> spatial_domain = Span({'x': [0, 1], 'y': [0, 1]}) >>> spatial_domain.sample(n=4, mode='random') tensor([[0.0108, 0.7643], [0.4477, 0.8015], [0.2063, 0.8087], [0.8735, 0.6349]]) >>> spatial_domain.sample(n=4, mode='grid') tensor([[0.0000, 0.0000], [0.3333, 0.0000], [0.6667, 0.0000], [1.0000, 0.0000], [0.0000, 0.3333], [0.3333, 0.3333], [0.6667, 0.3333], [1.0000, 0.3333], [0.0000, 0.6667], [0.3333, 0.6667], [0.6667, 0.6667], [1.0000, 0.6667], [0.0000, 1.0000], [0.3333, 1.0000], [0.6667, 1.0000], [1.0000, 1.0000]])
- is_inside(point, check_border=False)[source]
Check if a point is inside the ellipsoid.
- Parameters:
point (LabelTensor) – Point to be checked
check_border (bool) – Check if the point is also on the frontier of the hypercube, default
False
.
- Returns:
Returning
True
if the point is inside,False
otherwise.- Return type: