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

226 feature add simple first examplypy #230

Merged
merged 197 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
595db73
issue56-wip-create-code-skeleton
rawbby May 23, 2021
a2bdb5b
issue56-wip-implement-hard-coded-cuda-extension
rawbby Jul 4, 2021
0a23a5a
issue56-wip-change-cuda-stream-behavior-to-match-torch-roll
rawbby Jul 4, 2021
b69ff6f
issue56-wip-move-collision-operator-to-cuda
rawbby Jul 7, 2021
6aa9e6d
issue56-wip-added-cuda-check
rawbby Jul 8, 2021
47da720
issue56-wip-fixed-unsynced-cuda-calls
rawbby Jul 8, 2021
0f5a0db
issue56-wip-fixed-cleaned-up-operator
rawbby Jul 8, 2021
9b99bc9
issue56-wip-fixed-streaming-bug-and-added-collision-only
rawbby Jul 9, 2021
c5d9912
issue56-wip-modulization
rawbby Jul 25, 2021
1767169
issue56-wip-replace-hard-coded-cuda-with-code-generator
rawbby Aug 13, 2021
60efa48
issue56-replace-hard-coded-cuda-with-code-generator
rawbby Aug 14, 2021
b8b6a22
issue56-added-missing-buffer-swap
rawbby Aug 14, 2021
3497f98
issue56-fix-gencuda-typo
rawbby Aug 14, 2021
b2f0ce8
issue56-fix-gencuda
rawbby Aug 18, 2021
78c4d34
issue56-fix-gencuda
rawbby Aug 18, 2021
6a71d7a
issue56-lgtm-fix
rawbby Aug 18, 2021
89d9443
issue56-codeclimate-fix
rawbby Aug 18, 2021
3a23574
issue56-smal-fix
rawbby Aug 18, 2021
d452297
issue56-fixed-some-stuff
rawbby Aug 26, 2021
0dff5a0
issue56-fixed-first-time-setup-bug
rawbby Aug 26, 2021
bcba115
issue56-wip
rawbby Aug 27, 2021
c55334f
issue-56-change-import-strategy-and-utilize-relative-imports
rawbby Sep 8, 2021
6ae757f
issue-56-make-module-names-singular-as-it-is-a-general-programming-co…
rawbby Sep 8, 2021
e316985
issue-56-rename-gen_native-to-native_generator
rawbby Sep 8, 2021
041310d
issue-56-lattice-add-field-type-hints-and-make-properties-snake-case-…
rawbby Sep 8, 2021
01adc66
issue-56-lattice-add-use_native-field
rawbby Sep 8, 2021
d78318a
issue-56-generator-rework-one
rawbby Sep 8, 2021
071e9ca
issue-56-generator-fix-generation
rawbby Sep 8, 2021
f4ed9ec
issue-56-merge-algorithm-groups-into-one-file
rawbby Sep 8, 2021
862c73d
issue-56-generator-rename-signature-to-name
rawbby Sep 8, 2021
dfbe53b
issue-56-generator-add-generate-prefix-to-generating-methods
rawbby Sep 8, 2021
81d623e
issue-56-load-template-strings-from-file
rawbby Sep 8, 2021
48b580d
issue-56-generator-rename-append-buffer-methods
rawbby Sep 8, 2021
4031f64
issue-56-add-native-lattice-base-and-move-no_collision_mask
rawbby Sep 8, 2021
78cd8c8
issue-56-fixed-imports
rawbby Sep 8, 2021
7fbc439
issue-56-fixed-simulation-native
rawbby Sep 9, 2021
9b0882f
issue-56-fixed-setup
rawbby Sep 9, 2021
1ce0aa4
rework-core-generator
rawbby Nov 5, 2021
de45a90
soft-fix-core-generator
rawbby Nov 5, 2021
c4c425e
fix-core-generator
rawbby Nov 5, 2021
cf89a0b
fix-tests
rawbby Nov 5, 2021
54da144
fix-naming
rawbby Dec 20, 2021
6f32c27
tidy
rawbby Dec 20, 2021
5972121
tidy
rawbby Dec 20, 2021
09de359
tidy
rawbby Dec 20, 2021
35d60d3
rebase
rawbby Dec 20, 2021
4c69482
fixed_use_native_location_but_some_test_are_failing
rawbby Dec 23, 2021
453db50
added_changes_by_ollom
rawbby Jan 7, 2022
3e5e37b
fixed typo error. convergence now runs again with native
rawbby Feb 1, 2022
7a050f3
added version compare and reworked streaming
rawbby Jun 7, 2022
30985c8
Merge branch 'master' into issue56-write-pytorch-extension-for-stream…
rawbby Jun 7, 2022
e4d580d
many fixes but still broken
Jun 8, 2022
817ebae
move head to another pc
rawbby Jun 8, 2022
8f6052d
local_stash
Jun 8, 2022
258b39f
final fixes
Jun 8, 2022
692c6ac
fixed tests and modified benchmark tool
Jun 8, 2022
fd80ae6
fixed tests
Jun 8, 2022
33f6be2
patch_tests
rawbby Jun 8, 2022
b84fa2b
merged
Jun 8, 2022
bd0533e
reduce cognitive complexity
Jun 8, 2022
2342791
final cosmetics
Jun 9, 2022
bc94bca
fixed hash bug for detecting already installed natives and tidied up
Jun 9, 2022
376da43
get rid of the template directory. instead use a virtual file system …
Apr 18, 2023
bd97c5d
step one of the pipeline interface. Now it is possible to switch betw…
Apr 18, 2023
55d6e1f
update dependencies
May 22, 2023
9a46886
split streaming to read and write for pipeline interface
May 22, 2023
f2d496b
add multi pipeline support
May 22, 2023
6026c66
fixed naming issue
May 22, 2023
de4ca0d
add PipelineStep
May 22, 2023
88d0e0a
prepared pipeline
May 22, 2023
794ca5b
basic pipeline, not integrated well yet
May 23, 2023
ab47b09
coding session with mario. some tests and some rapid fixes.
May 23, 2023
c687a01
dirty wip
Jan 15, 2024
13857c7
add working pipeline + boundaries sample (cli) (dirty)
Jan 24, 2024
f40b60d
fixed resource bug
Mar 25, 2024
77c5a05
'v2'
May 13, 2024
3f27021
wip update
McBs May 27, 2024
fbc95a8
Changes by user
McBs May 27, 2024
aeb1836
update test_native_equilibrium_pu.py
McBs May 28, 2024
870d0cd
Working test_native_equilibrium_outlet_p.py --use-no-native
McBs May 28, 2024
bfc9951
update boundary tests and mount utility functions to lettuce
McBs May 29, 2024
7a449d1
wip
Jun 3, 2024
acd1e22
format
Jun 3, 2024
e72aaee
fixed_error_in_native_test
Jun 3, 2024
d00663a
tidy_tests
Jun 4, 2024
5dc2520
Merge pull request #8 from rawbby/test-branch
McBs Jun 4, 2024
0b0d42c
Refactor/rename directory, classes and update test_equilibrium_outlet…
McBs Jun 4, 2024
f2b0205
Add "stencil" parameter to TGV flow class within make_resolution func…
McBs Jun 5, 2024
44c9ab9
update observable_reporter.py and incompressible energy calculation
McBs Jun 6, 2024
7e87347
update observable_reporter.py
McBs Jun 7, 2024
2212894
update vtk_reporter.py
McBs Jun 7, 2024
feba193
Update README.rst
PhiSpel Jul 19, 2024
8d4d335
Merge pull request #165 from lettucecfd/master
PhiSpel Jul 19, 2024
0418ea0
Update setup.py
PhiSpel Jul 19, 2024
f57ce8a
started adapting A_first_example.ipynb
PhiSpel Jul 23, 2024
7af584e
fixed A_first_example.ipynb
PhiSpel Jul 23, 2024
b250315
get context for Observable from flow, not explicitly
PhiSpel Jul 23, 2024
7b024af
WIP tried fixing decaing turbulence
PhiSpel Jul 23, 2024
59899ab
fixed DecayingTurbulence.ipynb
PhiSpel Jul 25, 2024
bb15c4e
fixed DecayingTurbulence.ipynb
PhiSpel Jul 25, 2024
019d11e
fixed DecayingTurbulence.ipynb
PhiSpel Jul 25, 2024
04e6488
created u_pu, p_pu, and rho_pu properties for Flow
PhiSpel Jul 25, 2024
d9ce178
created u_pu, p_pu, and rho_pu properties for Flow
PhiSpel Jul 25, 2024
2f087d5
fixed obstacle.ipynb
PhiSpel Jul 25, 2024
71dcbb6
fixed obstacle.ipynb
PhiSpel Jul 25, 2024
f7fad48
Update CI.yml
PhiSpel Jul 26, 2024
d59794d
Update CI.yml
PhiSpel Jul 26, 2024
0388c58
reverted changes in equilibrium_boundary_pu.py
PhiSpel Jul 26, 2024
abb3d00
fixed Simulation_and_outputs.py
PhiSpel Jul 29, 2024
278dc7f
fixed convert_to_tensor and indexing (only wavenumbers in decaying tu…
PhiSpel Jul 29, 2024
e083c71
less console output in example
PhiSpel Jul 29, 2024
c087f71
fixed default in Simulation
PhiSpel Jul 29, 2024
d1b5607
Merge remote-tracking branch 'origin/cuda-native-philipp' into cuda-n…
PhiSpel Jul 29, 2024
2ff0da5
tried fixing porous_medium.ipynb - will wait for new boundary-develop…
PhiSpel Jul 31, 2024
6d98547
tidy up and rename native to cuda_native
Aug 1, 2024
08e1c69
minor import change
PhiSpel Aug 1, 2024
ba4c97e
Update CI.yml
PhiSpel Aug 1, 2024
fda13cc
Merge branch 'refs/heads/cuda-native-robert' into cuda-native-philipp
PhiSpel Aug 1, 2024
819d78f
Merge pull request #196 from lettucecfd/master
PhiSpel Aug 2, 2024
471eb2d
update README.rst
PhiSpel Aug 2, 2024
5acf318
Merge branch 'refs/heads/cuda-native-philipp' into 198-update-example…
PhiSpel Aug 2, 2024
2eefab7
updated kbc collision to not use lattice
PhiSpel Aug 2, 2024
4777aeb
updated anti bounce back outlet to not use lattice
PhiSpel Aug 2, 2024
be62437
updated regularized_collision.py to not use lattice
PhiSpel Aug 2, 2024
bea93cd
wip:
PhiSpel Aug 2, 2024
7665355
minor change - reverting underscore for stencil, collision, etc., in …
PhiSpel Aug 2, 2024
5c5b612
fixed 01b_first_example_obstacle.py
PhiSpel Aug 2, 2024
2668f68
wip: updated obstacle and tgv flows and examples. still issues with e…
PhiSpel Aug 4, 2024
0b8e2fd
Update CI.yml
PhiSpel Aug 5, 2024
8d6b165
Create ISSUE_TEMPLATE
PhiSpel Aug 5, 2024
f3dd345
Patch requirements matplotlib (#204)
McBs Aug 5, 2024
051da93
wip:
PhiSpel Aug 5, 2024
1896956
Merge pull request #205 from lettucecfd/master
PhiSpel Aug 5, 2024
6c1600e
Merge pull request #206 from lettucecfd/master
PhiSpel Aug 5, 2024
c013f24
Simulation_and_outputs.py to compare to original
PhiSpel Aug 5, 2024
872ec8d
Merge pull request #202 from lettucecfd/PhiSpel-patch-1
PhiSpel Aug 5, 2024
97f10a8
Merge pull request #203 from lettucecfd/PhiSpel-patch-2
PhiSpel Aug 5, 2024
5362612
wip - fixing taylorgreen.py and tests
PhiSpel Aug 5, 2024
661526c
wip - fixing taylorgreen.py and tests
PhiSpel Aug 5, 2024
cd266a2
Merge remote-tracking branch 'lettucecfd/198-update-examples-to-cuda-…
PhiSpel Aug 6, 2024
ba9291f
added collision to boundary to allow AntiBounceBackOutlet to stabilize
PhiSpel Aug 6, 2024
b7d5dcf
Rename ISSUE_TEMPLATE to ISSUE_TEMPLATE.md
PhiSpel Aug 6, 2024
6449bab
Create Bug Report.yml
PhiSpel Aug 6, 2024
25cfff3
Create Feature Request.yml
PhiSpel Aug 6, 2024
dc13b45
Delete .github/ISSUE_TEMPLATE.md
PhiSpel Aug 6, 2024
3ca5768
Rename Bug Report.yml to BUG_REPORT.yml
PhiSpel Aug 6, 2024
9a818c0
Update and rename Feature Request.yml to FEATURE_REQUEST.yml
PhiSpel Aug 6, 2024
d168f40
Update FEATURE_REQUEST.yml
PhiSpel Aug 6, 2024
6c8e0cf
Update BUG_REPORT.yml
PhiSpel Aug 6, 2024
a75de53
Update FEATURE_REQUEST.yml
PhiSpel Aug 6, 2024
a68a920
Update BUG_REPORT.yml
PhiSpel Aug 6, 2024
2dcd24a
pass flow instead of f to force
PhiSpel Aug 6, 2024
54ae0e7
Merge pull request #208 from lettucecfd/207-faulty-issue-template
PhiSpel Aug 6, 2024
da76322
update flows
PhiSpel Aug 6, 2024
db8aefe
combined kbc collision classes and reduced input parameters
PhiSpel Aug 6, 2024
a8afa3e
updated .gitignore for manually generated native code
PhiSpel Aug 6, 2024
99b2c09
fixed test_equilibrium_outlet_p_algorithm
PhiSpel Aug 6, 2024
89500c1
wip - fixing test_equilibrium_boundary_pu_algorithm
PhiSpel Aug 6, 2024
7e6f69a
fixed test_equilibrium_boundary_pu_algorithm
PhiSpel Aug 6, 2024
32be83b
fixed test_native_bgk_collision
PhiSpel Aug 6, 2024
0d76a16
convergence should be fixed
PhiSpel Aug 6, 2024
4f290c5
fixed PEP 8 comments and reran Couette.ipynb
PhiSpel Aug 14, 2024
17db593
Merge branch 'master' into 198-update-examples-to-cuda-native-archite…
PhiSpel Aug 14, 2024
c564f2d
removed deprecated init_f_neq option for convergence
PhiSpel Aug 14, 2024
f348b39
wip - fixing convergence test
PhiSpel Aug 14, 2024
75e6d1f
use_cuda_native will only be requested if ctx.device.type is not cpu
PhiSpel Aug 14, 2024
731bb4a
fixed convergence test!
PhiSpel Aug 14, 2024
4852a9b
show mlups in convergence test
PhiSpel Aug 14, 2024
e2b45c4
reran LidDrivenCavity.ipynb and DecayingTurbulence.ipynb
PhiSpel Aug 14, 2024
f613e3d
reverted README.rst
PhiSpel Aug 14, 2024
51f072a
updated remaining jupyter notebooks
PhiSpel Aug 14, 2024
ca328f7
Update setup.py
PhiSpel Aug 14, 2024
4e2abaa
Merge branch 'master-lettucecfd' into update-readme
PhiSpel Aug 14, 2024
a2ad45c
Merge remote-tracking branch 'lettucecfd/update-readme' into update-r…
PhiSpel Aug 14, 2024
177d50c
made TorchStencil private
PhiSpel Aug 14, 2024
a854b04
made TorchStencil public again
PhiSpel Aug 14, 2024
088acd7
made TorchStencil public again
PhiSpel Aug 14, 2024
b1480d1
structure click.option commands
McBs Aug 16, 2024
ed9afc3
Remove whitespaces
McBs Aug 16, 2024
cd44c7d
Update decayingturbulence.py
McBs Aug 16, 2024
f276123
Update liddrivencavity.py
McBs Aug 16, 2024
74b7918
Update liddrivencavity.py
McBs Aug 16, 2024
21c642f
Update observable_reporter.py
McBs Aug 16, 2024
31b3979
Merge pull request #216 from lettucecfd/McBs-patch-4
PhiSpel Aug 16, 2024
c75e826
Merge pull request #214 from lettucecfd/McBs-patch-2
PhiSpel Aug 16, 2024
2e4532b
Merge pull request #215 from lettucecfd/McBs-patch-3
PhiSpel Aug 16, 2024
0297d37
added warning if analytic solution of TGV is called in 3d after t=0
PhiSpel Aug 16, 2024
98155c2
Merge pull request #200 from lettucecfd/198-update-examples-to-cuda-n…
PhiSpel Aug 19, 2024
628b856
Update README.rst
PhiSpel Aug 21, 2024
5e32ba5
Update CI.yml (#228)
McBs Aug 21, 2024
4373e9a
Update CI.yml (#229)
McBs Aug 21, 2024
62d9304
Merge remote-tracking branch 'refs/remotes/lettucecfd/195-draft-a-new…
PhiSpel Aug 22, 2024
0983874
Merge remote-tracking branch 'refs/remotes/lettucecfd/update-readme' …
PhiSpel Aug 22, 2024
ef9830b
added simplest TGV example
PhiSpel Aug 22, 2024
4e236fb
added link in README.rst
PhiSpel Aug 22, 2024
e8d84d7
pep8 cosmetics
PhiSpel Aug 22, 2024
f4e7c31
Merge branch '195-draft-a-new-release' into 226-feature-add-simple-fi…
McBs Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 36 additions & 43 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,65 +40,60 @@ Resources
.. _Video: https://www.youtube.com/watch?v=7nVCuuZDCYA
.. _Code: https://github.com/lettucecfd/lettuce-paper


Resources
---------

- `Documentation`_
- Presentation at CFDML2021 - `Preprint`_ | `Slides`_ | `Video`_ | `Code`_

.. _Documentation: https://lettuceboltzmann.readthedocs.io
.. _Preprint: https://arxiv.org/pdf/2106.12929.pdf
.. _Slides: https://drive.google.com/file/d/1jyJFKgmRBTXhPvTfrwFs292S4MC3Fqh8/view
.. _Video: https://www.youtube.com/watch?v=7nVCuuZDCYA
.. _Code: https://github.com/lettucecfd/lettuce-paper

Getting Started
---------------

The following Python code will run a two-dimensional Taylor-Green vortex on a GPU:
To find some very simple examples of how to use lettuce, please have a look
at the examples_. These will guide you through lettuce's main features. The
simplest example is:

.. code:: python
https://github.com/lettucecfd/lettuce/blob/ef9830b59c6ad50e02fdf0ce24cc47ea520aa354/examples/00_simplest_TGV.py#L6-L21

import torch
import lettuce as lt

lattice = lt.Lattice(lt.D2Q9, device='cuda', dtype=torch.float64, use_native=False) # for running on cpu: device='cpu'
flow = lt.TaylorGreenVortex2D(resolution=128, reynolds_number=100, mach_number=0.05, lattice=lattice)
collision = lt.BGKCollision(lattice, tau=flow.units.relaxation_parameter_lu)
streaming = lt.StandardStreaming(lattice)
simulation = lt.Simulation(flow=flow, lattice=lattice, collision=collision, streaming=streaming)
mlups = simulation.step(num_steps=1000)
print("Performance in MLUPS:", mlups)

More advanced examples_ are available as jupyter notebooks.

Please ensure you have Jupyter installed to run these notebooks.
Please ensure you have Jupyter installed to run the Jupyter notebooks.

.. _examples: https://github.com/lettucecfd/lettuce/tree/master/examples

Installation
------------

* Install the anaconda package manager from www.anaconda.org
* Create a new conda environment and install PyTorch::
* Install the anaconda or miniconda package manager from www.anaconda.org
* Create a new conda environment and activate it::

conda create -n lettuce
conda activate lettuce

* Follow the recommendations at https://pytorch.org/get-started/locally/ to
install pytorch based on your GPU's CUDA version. You may need to install
the nvidia toolkit. You may follow the instructions at https://developer
.nvidia.com/cuda-downloads. You may need to check the compatibility of your
NVIDIA driver with the desired CUDA version:
https://docs.nvidia.com/deploy/cuda-compatibility/. To get your CUDA version,
run::

conda create -n lettuce -c pytorch -c nvidia pytorch pytorch-cuda=12.1
nvcc --version

* Activate the conda environment::
* For CUDA 12.1 (if supported by your GPU) use::

conda install pytorch pytorch-cuda=12.1 -c pytorch -c nvidia

* Install the remaining dependencies::

conda activate lettuce
conda install -c pytorch -c conda-forge matplotlib pytest click pyevtk mmh3 h5py scipy pandas numpy

* Install all requirements::
* Clone this repository from github and change to it::

conda install -c conda-forge -c anaconda matplotlib pytest click pyevtk h5py mmh3
git clone https://github.com/lettucecfd/lettuce
cd lettuce

* Clone this repository from github
* Change into the cloned directory
* Run the install script::
* If you want to only **USE** lettuce, run the install script::

python setup.py install

* If you are a **developer**, do this to update the lettuce package when running a script::

python setup.py develop

* Run the test cases::

python setup.py test
Expand All @@ -107,15 +102,14 @@ Installation

lettuce --no-cuda convergence

* For running a CUDA-driven LBM simulation on one GPU omit the `--no-cuda`. If CUDA is not found,
make sure that cuda drivers are installed and compatible with the installed cudatoolkit
(see conda install command above).
* For running a CUDA-driven LBM simulation on one GPU omit the `--no-cuda`.
If CUDA is not found, make sure that cuda drivers are installed and
compatible with the installed cudatoolkit (see conda install command above).

* Check out the performance, running on GPU::

lettuce benchmark


Citation
--------
If you use Lettuce in your research, please cite the following paper::
Expand All @@ -128,7 +122,6 @@ If you use Lettuce in your research, please cite the following paper::
organization={Springer Nature}
}


Credits
-------
We use the following third-party packages:
Expand Down
21 changes: 21 additions & 0 deletions examples/00_simplest_TGV.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
This file showcases the simplicity of the lettuce code.
The following code will run a two-dimensional Taylor-Green vortex on GPU.
"""

import torch
import lettuce as lt

flow = lt.TaylorGreenVortex(
lt.Context(dtype=torch.float64), # for running on cpu: device='cpu'
resolution=128,
reynolds_number=100,
mach_number=0.05,
stencil=lt.D2Q9
)
simulation = lt.Simulation(
flow=flow,
collision=lt.BGKCollision(tau=flow.units.relaxation_parameter_lu),
reporter=[])
mlups = simulation(num_steps=1000)
print("Performance in MLUPS:", mlups)
3 changes: 2 additions & 1 deletion lettuce/ext/_flows/liddrivencavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def boundaries(self):
BounceBackBoundary(boundary),
# moving fluid on top# moving bounce back top
EquilibriumBoundaryPU(
self.context, top,
self.context,
top,
[float(self.units.characteristic_velocity_pu), 0.0]
),
]
5 changes: 2 additions & 3 deletions lettuce/util/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ def equilibrium(self, m):


"""
D3Q19 is not implemented, yet. Also, the moments should be ordered so that
1...D+1 correspond to momentum,
which is no the case for this matrix.
D3Q19 is not implemented, yet. Also, the moments should be ordered so that
1...D+1 correspond to momentum, which is no the case for this matrix.
"""


Expand Down