You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
First of this is not an urgent matter since after the error the plot is still shown correctly.
The function plotter.plot_samples() results in an error when your problem definition includes a Condition using data.
Problem definition
class Heat2D(TimeDependentProblem, SpatialProblem):
# Define these yourself
LENGTH_X = 82
LENGTH_Y = 70
DURATION = 2284
output_variables = ['u']
spatial_domain = Span({'x': [0, LENGTH_X], 'y': [0, LENGTH_Y]})
temporal_domain = Span({'t': [0, DURATION]})
def heat_equation_2D(input_, output_):
'''1'''
# c is thermal diffusivity, variates for different materials so google
c = (0.01/torch.pi) ** 0.5
du = grad(output_, input_)
ddu = grad(du, input_, components=['dudx','dudy'])
return (
du.extract(['dudt']) -
(c**2)*(ddu.extract(['ddudxdx']) + ddu.extract(['ddudydy']))
)
def nil_dirichlet_x(input_, output_):
'''2 and 3'''
du = grad(output_, input_)
u_expected_boundary = 0.0
return du.extract(['dudx']) - u_expected_boundary
def nil_dirichlet_yL(input_, output_):
'''4'''
du = grad(output_, input_)
u_expected_boundary = 0.0
return du.extract(['dudy']) - u_expected_boundary
def nil_dirichlet_y0(input_, output_):
'''5'''
# TODO: make this conditionally on if door is open
du = grad(output_, input_)
u_expected_boundary = 0.0
return du.extract(['dudy']) - u_expected_boundary
def initial_condition(input_, output_):
'''6'''
u_expected_initial = torch.sin(torch.pi*input_.extract(['x']))
return output_.extract(['u']) - u_expected_initial
conditions = {
'boundx0': Condition(location=Span({'x': 0, 'y': [0, LENGTH_Y], 't': [0, DURATION]}), function=nil_dirichlet_x),
'boundxL': Condition(location=Span({'x': LENGTH_X, 'y': [0, LENGTH_Y], 't': [0, DURATION]}), function=nil_dirichlet_x),
'boundy0': Condition(location=Span({'x': [0, LENGTH_X], 'y': 0, 't': [0, DURATION]}), function=nil_dirichlet_y0),
'boundyL': Condition(location=Span({'x': [0, LENGTH_X], 'y': LENGTH_Y, 't': [0, DURATION]}), function=nil_dirichlet_yL),
'initial': Condition(location=Span({'x': [0, LENGTH_X], 'y': [0, LENGTH_Y], 't': 0}), function=initial_condition),
'heat_eq': Condition(location=Span({'x': [0, LENGTH_X], 'y': [0, LENGTH_Y], 't': [0, DURATION]}), function=heat_equation_2D),
'data': Condition(input_points=X_input_tensor , output_points=X_output_tensor),
}
Describe the bug
First of this is not an urgent matter since after the error the plot is still shown correctly.
The function plotter.plot_samples() results in an error when your problem definition includes a Condition using data.
Problem definition
Pinn:
and
gives
and when plotting
I get
followed by a plot showing all the function samples correctly.
Expected behavior
I think the plot_samples method should be checking whether the location is an input-output condition before trying to plot it
The text was updated successfully, but these errors were encountered: