GithubHelp home page GithubHelp logo

agdestein / incompressiblenavierstokes.jl Goto Github PK

View Code? Open in Web Editor NEW
41.0 2.0 9.0 427.34 MB

Incompressible Navier-Stokes solver

Home Page: https://agdestein.github.io/IncompressibleNavierStokes.jl/dev/

License: MIT License

Julia 100.00%
navier-stokes pde finite-volumes differentiable-physics computational-fluid-dynamics

incompressiblenavierstokes.jl's Introduction

Logo Logo

IncompressibleNavierStokes

Documentation Workflows Code coverage Quality assurance
Stable Dev Build Status Coverage Aqua QA

This package implements energy-conserving solvers for the incompressible Navier-Stokes equations on a staggered Cartesian grid. It is based on the Matlab package INS2D/INS3D. The simulations can be run on the single/multithreaded CPUs or Nvidia GPUs.

This package also provides experimental support for neural closure models for large eddy simulation.

Installation

To install IncompressibleNavierStokes, open up a Julia-REPL, type ] to get into Pkg-mode, and type:

(v1.10) pkg> add IncompressibleNavierStokes

which will install the package and all dependencies to your local environment. Note that IncompressibleNavierStokes requires Julia version 1.9 or above.

See the Documentation for examples of some typical workflows. More examples can be found in the examples directory.

Source code for paper

See here for the source code used in the paper Discretize first, filter next: learning divergence-consistent closure models for large-eddy simulation.

Gallery

The velocity and pressure fields may be visualized in a live session using Makie. Alternatively, ParaView may be used, after exporting individual snapshot files using the save_vtk function, or the full time series using the VTKWriter processor.

Actuator (2D) Backward Facing Step (2D) Decaying Turbulence (2D) Taylor-Green Vortex (2D)
Actuator (3D) Backward Facing Step (3D) Decaying Turbulence (3D) Taylor-Green Vortex (3D)

IncompressibleNavierStokes also supports adding a temperature equation.

iceandfire_100x100x200.mp4

Demo

The following example code using a negative body force on a small rectangle with an unsteady inflow. It simulates a wind turbine (actuator) under varying wind conditions.

Make sure to have the GLMakie and IncompressibleNavierStokes installed:

using Pkg
Pkg.add(["GLMakie", "IncompressibleNavierStokes"])

Then run run the following code to make a short animation:

using GLMakie
using IncompressibleNavierStokes

# A 2D grid is a Cartesian product of two vectors
n = 40
x = LinRange(0.0, 10.0, 5n + 1)
y = LinRange(-2.0, 2.0, 2n + 1)

# Boundary conditions
boundary_conditions = (
    # Inlet, outlet
    (
        # Unsteady BC requires time derivatives
        DirichletBC(
            (dim, x, y, t) -> sin/ 6 * sin/ 6 * t) + π / 2 * (dim() == 1)),
            (dim, x, y, t) ->/ 6)^2 *
                cos/ 6 * t) *
                cos/ 6 * sin/ 6 * t) + π / 2 * (dim() == 1)),
        ),
        PressureBC(),
    ),

    # Sides
    (PressureBC(), PressureBC()),
)

# Actuator body force: A thrust coefficient distributed over a thin rectangle
inside(x, y) = abs(x - 2.0)  0.055 && abs(y)  0.5
bodyforce(dim, x, y, t) = dim() == 1 && inside(x, y) ? -1.82 : 0.0

# Build setup and assemble operators
setup = Setup(x, y; Re = 100.0, boundary_conditions, bodyforce);

# Initial conditions (extend inflow)
ustart = create_initial_conditions(setup, (dim, x, y) -> dim() == 1 ? 1.0 : 0.0);

# Solve unsteady Navier-Stokes equations
solve_unsteady(;
    setup, ustart, tlims = (0.0, 48.0), Δt = 0.05,
    processors = (
        anim = animator(; setup, path = "vorticity.mp4", nupdate = 4),
        log = timelogger(),
    ),
)

The resulting animation is shown below.

vorticity.mp4

Similar projects

incompressiblenavierstokes.jl's People

Contributors

agdestein avatar dependabot[bot] avatar luisaforozco avatar pabrod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

incompressiblenavierstokes.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Error while 'using IncompressibleNavierStokes'

Hi,
I am exploring the package by following the instructions from https://agdestein.github.io/IncompressibleNavierStokes.jl/dev/generated/LidDrivenCavity2D/
I am using Julia version 1.5.3.
When I type add IncompressibleNavierStokes, I get no errors.
However, when I type using IncompressibleNavierStokes, I get the following error:

ERROR: LoadError: LoadError: syntax: invalid assignment location "; hx, hy" around /home/hemaditya/.julia/packages/IncompressibleNavierStokes/d4l3M/src/grid/max_size.jl:7 Stacktrace: [1] top-level scope at /home/hemaditya/.julia/packages/IncompressibleNavierStokes/d4l3M/src/grid/max_size.jl:1 [2] include at ./Base.jl:368 [inlined] [3] include(::String) at /home/hemaditya/.julia/packages/IncompressibleNavierStokes/d4l3M/src/IncompressibleNavierStokes.jl:7 [4] top-level scope at /home/hemaditya/.julia/packages/IncompressibleNavierStokes/d4l3M/src/IncompressibleNavierStokes.jl:28 [5] top-level scope at none:2 [6] eval at ./boot.jl:331 [inlined] in expression starting at /home/hemaditya/.julia/packages/IncompressibleNavierStokes/d4l3M/src/grid/max_size.jl:1 in expression starting at /home/hemaditya/.julia/packages/IncompressibleNavierStokes/d4l3M/src/IncompressibleNavierStokes.jl:28

It seems that the error arises when trying to include the max_size.jl function. Could you please help me around this error, since I am not yet an expert in Julia programming syntax?

Cheers

UndefineVer

ERROR: UndefVarError: StateObserver not defined
Stacktrace:
[1] top-level scope
@ f:\IncompressibleNavierStokes.jl-main\examples\Actuator2D.jl:87
i m using julia v1.9 facing above error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.