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

Varying inflow velocity using bc_profile #111

Open
DynoAbd786-Uni opened this issue Feb 27, 2025 · 4 comments
Open

Varying inflow velocity using bc_profile #111

DynoAbd786-Uni opened this issue Feb 27, 2025 · 4 comments

Comments

@DynoAbd786-Uni
Copy link

Hi. I'm looking into varying the velocity of inflow to be time-dependant, e.g. following a sinusoidal flow pattern where peaks represent max velocity at the inlet. Is XLB capable of this if I create a bc_profile with the ZouHeBC

@DynoAbd786-Uni DynoAbd786-Uni changed the title bc_profile Varying inflow velocity using bc_profile Feb 27, 2025
@hsalehipour
Copy link
Collaborator

Hi @DynoAbd786-Uni . Yes, XLB is capable of that but right now, that particualr use case is not shown in any of our examples. With our current APIs, this is what you would need to do to enable this feature (althoguh this could be further improved for performance):

  1. redefine your bc objec every time that its profile needs to change with having something like this:
    bc_left = ZouHeBC("velocity", profile=bc_profile(time), indices=inlet)

  2. Call these functions after redefining the new BC profile (see these line of the code for reference):

    bc_mask, missing_mask = self._process_boundary_conditions(self.boundary_conditions, bc_mask, missing_mask)

        # Process boundary conditions and update masks
        bc_mask, missing_mask = stepper._process_boundary_conditions([bc_left], bc_mask, missing_mask)
        # Initialize auxiliary data if needed
        f_0, f_1 = stepper._initialize_auxiliary_data([bc_left], f_0, f_1, bc_mask, missing_mask)
  1. Note the input to bc_profile is time here so obviously you should change bc_profile as well.

Hopefully this will get you going in the right track. But please let me know if you have any further issues.

@DynoAbd786-Uni
Copy link
Author

Thanks for your help.

I've looked into the source code and have tried to make a custom class that implements updating the timestep for the ZouHe bc rather than recreating the bc per run cycle. Every run cycle in my code calls to update the timestep according to the current timestep in the run loop.

it is inheriting the existing ZouHe bc class and is overriding some JAX and WARP functions. I think it essentially is a direct copy of the ZouHe class but just with an added update_timestep function and small (1-5 line(s)) modifications to those overridden commands to use the updated timestep variable rather than 0, and the updated bc condition based off the timestep. Not much more has changed.

This is running on the latest release version v0.2.1.

@hsalehipour
Copy link
Collaborator

That sounds great. Please see the contribution guidelines and submit a PR 😊.

@DynoAbd786-Uni
Copy link
Author

DynoAbd786-Uni commented Mar 3, 2025

I'd be happy to, but some aspects of my code serve as my dissertation. I'd be happy to contribute once my dissertation has been handed in if that's OK 😊.

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

2 participants