SciML / MethodOfLines.jl

Automatic Finite Difference PDE solving with Julia SciML
https://docs.sciml.ai/MethodOfLines/stable/
MIT License
160 stars 31 forks source link

Ifelse condition on a BC #296

Open GHE-HS opened 1 year ago

GHE-HS commented 1 year ago

Hi,

While (again) modelling heat exchangers, I bumped into another issue/limitation.

I simulate a heat exchanger with two fluids. Everything works as should but I arrived to the point where I would like to have a variable fluid direction. The PDE for the fluid looks something like: $$ \frac{{\partial T_a(t, x)}}{{\partial t}} = v_a(t) \frac{{\partial T_a(t, x)}}{{\partial x}} + h \left( T_b(t, x) - T_a(t, x) \right) $$ And the corresponding BC should be somehting like: bcs = [ ..., Ti ~ ifelse(v_a(t) > 0, Ta(t, 0), Ta(t, 1)), ... ] In this example Ti is the prescribed temperature at the inlet of the heat exchanger, but the inlet is supposed to change depedning on the flow direction.

In short, it would be a conditional boundary condition, but I had no success when implementing it unfortunately. Any workaround?

I hope my question was clear! Thanks

xtalax commented 1 year ago

I'm afraid you just need to add 2 bcs at each end for this, the solver only takes the upstream one in to account