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
Hi all,
I have been trying to implement Hard IC for follwing initial conditions:
h = np.where(x < 5, 2, 0.125)
u = 0
z = 0
I tried to use something like this:
def hard_constraints(a,b):
x = a[:,0:1]
t = a[:,1:2]
h = b[:,0:1]
u = b[:,1:2]
z = b[:,2:3]
condition = x <= dam_location
t_zero_condition = (t == 0) # Condition for t being 0
# Calculate hard_IC_h for both cases
hard_IC_h_t_zero = torch.where(condition, dam_height, downstream_depth) + h * t
hard_IC_h_not_zero = h
# Assign values based on conditions
hard_IC_h = torch.where(t_zero_condition, hard_IC_h_t_zero, hard_IC_h_not_zero)
# Calculate hard_IC_u for both cases
hard_IC_u_t_zero = u * t
hard_IC_u_not_zero = u
# Assign values based on conditions for hard_IC_u
hard_IC_u = torch.where(t_zero_condition, hard_IC_u_t_zero, hard_IC_u_not_zero)
hard_IC_z_t_zero = z * t
hard_IC_z_not_zero = z
# Assign values based on conditions for hard_IC_u
hard_IC_z = torch.where(t_zero_condition, hard_IC_u_t_zero, hard_IC_u_not_zero)
return torch.concat((hard_IC_h, hard_IC_u, hard_IC_z), dim=1)
net.apply_output_transform(hard_constraints)
The initial conditions are met but the output for the rest of the time conditions are not okay at all. I tried using soft contraints, but the network always struggles near the discontinuity zone.
Any help on how to setup the Hard IC is greatly appreciated. Many thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I have been trying to implement Hard IC for follwing initial conditions:
I tried to use something like this:
The initial conditions are met but the output for the rest of the time conditions are not okay at all. I tried using soft contraints, but the network always struggles near the discontinuity zone.
Any help on how to setup the Hard IC is greatly appreciated. Many thanks.
Beta Was this translation helpful? Give feedback.
All reactions