Originally posted by **martinsgronli** August 3, 2023
Hi!
Is there a way to use the heaviside function in the PDE expression?
I want to do something like:
`eq = PDE({"T": f"(1 * heaviside(T - 273, 0.5) + 2 * heaviside(273 - T, 0.5)) * laplace(T)", bc = [bc_x, bc_y])
eq.solve(field, t_end, dt)
`
It looks like I need to register the heaviside function as a new operator, but I am not sure how to do this.
I am asking because I want to choose a thermal conductivity of 1 when the temperature T > 273 and 2 when T < 273 while solving the 1D heat equation. Instead of using the heaviside function, I have also tried to write the f string in the first line with a condition for the temperature. However, it looks like I cannot access the temperature inside such a condition.
Discussed in https://github.com/zwicker-group/py-pde/discussions/444