lettucecfd / lettuce

Computational Fluid Dynamics based on PyTorch and the Lattice Boltzmann Method
MIT License
223 stars 39 forks source link

added a ObservableReporter.save and a Simulation.save_reporters method #124

Closed PhiSpel closed 2 years ago

PhiSpel commented 2 years ago

My test code:

import torch
from lettuce import BGKCollision, StandardStreaming, Lattice, D2Q9, TaylorGreenVortex2D, Simulation
import lettuce as lt

device = "cpu"   # for running on cpu: device = "cpu"
dtype = torch.float32

lattice = Lattice(D2Q9, device, dtype)
flow = TaylorGreenVortex2D(resolution=256, reynolds_number=10, mach_number=0.05, lattice=lattice)
collision = BGKCollision(lattice, tau=flow.units.relaxation_parameter_lu)
streaming = StandardStreaming(lattice)
simulation = Simulation(flow=flow, lattice=lattice,  collision=collision, streaming=streaming)

energy = lt.IncompressibleKineticEnergy(lattice,flow)
reporter = lt.ObservableReporter(energy, interval=5, print_to_screen=True, save_to_file=True, filename_base="./data/output")
simulation.reporters.append(reporter)

mlups = simulation.step(num_steps=10)

simulation.save_reporters()

print("Performance in MLUPS:", mlups)
Olllom commented 2 years ago

I will close this for now for the reasons mentioned above.