Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self-defined boundary conditions #13

Open
HarondFinch opened this issue Jan 19, 2025 · 5 comments
Open

self-defined boundary conditions #13

HarondFinch opened this issue Jan 19, 2025 · 5 comments

Comments

@HarondFinch
Copy link

Wonderful work here, greatly appreciate the contributions made by the authors!
JAX-Fluids is now a well-developed package, yet l find that the default classes of boundary conditions are not suitable for my applications. l am creating a combustor simulation with an injection boundary condition, this boundary condition is more like the Velocity-Inlet boundary conditions in Ansys Fluent, where l take the extrapolated pressure as the pressure in halo grids, but the velocity and tempreature in halo grids are given by user-defined values (they could be functions of extrapolated pressure). By applying this boundary conditions, the injection speed can adapt to the pressure in the combustor.
In order to do that, do l need to write a self-defined boundary condition as a new class? How should l integrate this class to your coding framework? l'll appreciate it so much if you could enlight me a little. Looking forward to your reply!

@biao-geng-me
Copy link

Hello, I was going to ask a related question regarding the boundary condition setup and found this open issue. Please let me know if I should open a new issue.

I went through a few examples and the source code. It seems that each face of the domain could potentially have a list of boundary condition setup, each with its own type. I guess this is for setting up non-homogeneous BCs for different variables, for example, Dirichilet for velocity and Neumann for pressure. However, when looking at the boundary update function face_halo_update in the BoundaryConditionMaterial class, it seems that the primitives are updated at once here

                primitives = primitives.at[slices_fill].mul(1 - mask)
                primitives = primitives.at[slices_fill].add(halos_primes * mask)

Could you please clarify on this? This is related to OP's question on how to set different boundary condition types for pressure and velocity. Thank you!

@dbezgin
Copy link
Collaborator

dbezgin commented Jan 31, 2025

Hi,

thank you for your comments and your interest in JAX-Fluids.

@HarondFinch, excuse the late reply. Just to understand what you are aiming for. The pressure from the interior of the domain would be extrapolated to the halo cells and velocity + temperature (in the halo cells) are user-defined values. Constant extrapolation (i.e., zero-gradient) for pressure? Do you explicitly want the velocity and temperature functions to depend on the extrapolated pressure?

You could define this new type of boundary condition under halos/outer/material.py as a new function "velocity_inlet" similar to the existing dirichlet function. Your new boundary condition "velocity_inlet" would then be called within the face_halo_update routine. Please let us know if there is anything unclear about the implementation. Otherwise, we could provide a simplified version of your BC, in which pressure is constantly extrapolated and velocity and density are user-defined values.

@dbezgin
Copy link
Collaborator

dbezgin commented Jan 31, 2025

@biao-geng-me Yes, you can have multiple boundary conditions at each face. This is meant for setting different BCs in different patches of a given face location. I.e., you can set up a case in which the west boundary consists of multiple inlets (e.g., defined by Dirichlet conditions) and multiple walls in between. Similarly, you could set part of the boundary to be an isothermal wall and another part of the same wall to be adiabatic.

This is, however, not meant for specifying different BCs for different variables.

@HarondFinch
Copy link
Author

Hi,

thank you for your comments and your interest in JAX-Fluids.

@HarondFinch, excuse the late reply. Just to understand what you are aiming for. The pressure from the interior of the domain would be extrapolated to the halo cells and velocity + temperature (in the halo cells) are user-defined values. Constant extrapolation (i.e., zero-gradient) for pressure? Do you explicitly want the velocity and temperature functions to depend on the extrapolated pressure?

You could define this new type of boundary condition under halos/outer/material.py as a new function "velocity_inlet" similar to the existing dirichlet function. Your new boundary condition "velocity_inlet" would then be called within the face_halo_update routine. Please let us know if there is anything unclear about the implementation. Otherwise, we could provide a simplified version of your BC, in which pressure is constantly extrapolated and velocity and density are user-defined values.

Thank you very much, it is very kind of you to offer your help! l understand what you mean but still l want to learn how you would write a simplified version of my BC, again, thank you so much for your kind help!

@biao-geng-me
Copy link

@dbezgin Thank you for the explanation. Much apprreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants