Sympy Max not working in PDE (cannot determine truth value of Relational)

I am interesting in modelling a damage model, where if a PINNs output exceeds a value then the governing equations changes, in linear elastic model only i need to check for the energy associated with deformation, and when it exceeds a certain value it needs to change the governing equation.

I am interested in solving: {r1, r2 are pre-defined, |p| is value associated with energy, f is variable of interest}

f = -Max(|p| - r1,0)/r2

Unfortunately, the Max is not working,

Thus I tried to approach the same by defining criteria check on by importing the equations for the same. But then it encounters type error with Sympy and float and I am unable to convert the sympy to numpy/float

    DM1 = PointwiseInteriorConstraint(
        criteria = Equations.equations["p"] < r1,
        bounds={x: bounds_x, y: bounds_y, t: bounds_t},
        lambda_weighting = {"f1": 1.0},
        parameterization={t: bounds_t, x: bounds_x, y: bounds_y},
    domain.add_constraint(DM1, "damage_model_1")

Please help me with this,

Thank you


Hi @nihalpushkar11

Max should work, its registered in our sympy converter. With no additional information, its hard to tell what the issue is. One option could be to rewrite this function to use the Heaviside operator instead:

a = (|p| - r1)
f = -Heaviside(a) * (a) / r2

Edit: I’m assuming this is referring this error here:

line 376, in __nonzero__
    raise TypeError("cannot determine truth value of Relational")
TypeError: cannot determine truth value of Relational

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

For documentation purposes, this is a continuation of this thread:

hello @ngeneva ,
Thanks for the reply and suggestion. Now I am successfully able to implement what I intend to.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.