Varying inflow velocity using bc_profile
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
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):
-
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) -
Call these functions after redefining the new BC profile (see these line of the code for reference): https://github.com/Autodesk/XLB/blob/09a464801f354be863c7038bb6321c1fc2617a76/xlb/operator/stepper/nse_stepper.py#L86
# 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)
- 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.
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.
That sounds great. Please see the contribution guidelines and submit a PR 😊.
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 😊.