CliMA / Oceananigans.jl

🌊 Julia software for fast, friendly, flexible, ocean-flavored fluid dynamics on CPUs and GPUs
https://clima.github.io/OceananigansDocumentation/stable
MIT License
987 stars 193 forks source link

General question: how to build laminar flow with one particle #1572

Closed maeckha closed 3 years ago

maeckha commented 3 years ago

Hello, maybe this question is not specific enough but I am trying to understand how to build a laminar flow with a single particle. It is my understanding that I would need a two-dimensional grid with a topology=(Periodic, Flat, Bounded) (because the same one is used in the convecting_plankton example). But how do I generate the correct inlet and outlet boundary conditions? Do the docs provide this information? I should say that I am not an engineer but my background is computer science with a current application in ecology. So I know how to write and read code but am not an expert in physics. Can you point me into a direction where I can gather the needed understanding to tackle such problems with Oceananigans? Thank you!

glwagner commented 3 years ago

I think you've started in the right place by looking at the examples. I suggest reading a few more examples! The "Model setup" section in the documentation should also be useful.

If you can describe your problem in more detail then we may be in a better position to help. Here's some guiding questions:

The term "laminar flow" is not specific --- it's possible to have laminar flows in both two and three dimensions, and in bounded or periodic domains and with a variety of boundary conditions.

I'm not sure what you mean by "single particle". We have some functionality for modeling what we call "Lagrangian particles", which are like grains of sand that are advected by the flow. We can explain how to model a single Lagrangian particle, if that is indeed what you are trying to do.

maeckha commented 3 years ago

Thank you for your response and for providing the guiding questions. I summarized the motivation and context of the project below.

If you can describe your problem in more detail then we may be in a better position to help. Here's some guiding questions: What is the physical situation you are trying to model? Can you describe the geometry of your problem and its motivation?

It is a thesis project about the dispersal and migration of fish larvae in the sea. Juveniles from a coral reef fish population can return to their natal reef after being dispersed into the open ocean by the currents. Fish larvae, in particular, have the ability to swim directionally and increasingly fast during ontogeny, indicating that they may not only disperse, but also migrate to their natal reef using environmental signals. How and when larvae use local and large-scale cues remains a mystery. To bring light into this we want to build a simulation where we simulate the ocean including some Lagrangian particles in it(which simulate the larvae). Then we will try out several possible factors, which might help the larvae to find their natal reefs after being dispersed. For this we picked Oceananigans as a tool. We want to use it to build a module where you can activate several simulated factors like odor(through a continuity equation), swarm behaviour or navigation. Ideally this would be another great example for Oceananigans as a whole. Our plan is to use the laminar flow with single particle – case as a starting point to build the other cases (more particles, turbulent flow, etc.) on.

What is the dimensionality of your problem? Most fluids problems of interest are either two- or three-dimensional. You have implied that your problem is two-dimensional but did not state this explicitly.

We plan to do this two-dimensionaly at first since it is „just“ a bachelor’s thesis.

What boundary conditions would you like to impose? You have stated that you want to generate inlet and outlet boundary conditions. But the domain you mentioned is periodic in x and bounded in z. Would you like to impose an inlet and outlet flow in the z direction (thus you would impose inflow and outflow conditions on the vertical velocity)? Note, it may be challenging to impose outlet boundary conditions, but we are happy to help if this is what you want to do.

Although I did a lot of reading on CFD basics, I yet have to fully grasp the different kinds of boundary conditions(especially differences between periodic, bounded and flat). Concerning laminar flow I have been reading about inlet and outlet conditions. That’s why I have been thinking about those in particular but maybe it would be better without the outlet ones.

Does your problem involve tracer fields? Would you like to simulate the trajectory of particles advected in your flow as well?

I am not sure about that question, so I will come back to it.

glwagner commented 3 years ago

Great, thank you for providing context!

I would focus on setting up a two-dimensional flow first, and then tackle the problem of adding particles to the simulation that behave in the manner you prescribe. There's no reason to do both of these things at the same time and adding particles to an existing simulation will hopefully be straightforward.

In Oceananigans, Periodic, Bounded, and Flat do not refer to boundary conditions, but to the "topology" of a domain. Envision a two-dimensional domain as a piece of paper. If the domain is Bounded in both direction, then by default no fluid can enter or leave the paper (in addition to other conditions imposed on the physics). If the domain is Periodic in one direction, then its as if the paper is curled into a cylinder: fluid leaving the right side of the domain reappears on the left side. This is what it means for a domain to be Periodic. When a direction has a Periodic topology, we impose "periodic boundary conditions" (though a better way to think about this scenario is that there is no boundary at all!) Periodic topologies are convenient for all sorts of problems, which is why you see them cropping up in the examples frequently. If you can use a domain that is periodic in the "streamwise" direction (the direction oriented with the primary direction of your flow), you may make your life a bit simpler.

A Flat topology is the Oceananigans way of saying that your problem does not vary in that direction. If one direction is Flat, then your problem is two-dimensional. So you don't impose boundary conditions in Flat directions either.

When a direction is Bounded, you may impose Value, Gradient, and Flux boundary conditions on tracers and the components of the velocity field that are tangential to the boundary. (Note that the velocity component normal to the boundary is special. It is trickier to set boundary conditions on this component, and I don't think you will need to do this for your project.) If your domain is periodic in x and bounded in z, then you only need to worry about imposing boundary conditions at the top and bottom on tracers, u, and v.

I am happy to help more if you like. You can also try to force your flow to drive motion, rather than by imposing boundary conditions. Sometimes this approach is a bit simpler than forcing a flow by applying boundary conditions.

ali-ramadhan commented 3 years ago

I hope it's okay with everyone if I convert this to a GitHub discussion.