This repo contains the FV-SPARCS reader module (compat with GAIAv3)
Howto use:
from fvsparcs import *
Usecases for the module
# Check what cases are in current directory (change with os.chdir)
print(getCases())
# If you only have one run in the directory:
s = Simulation()
# For a specific case:
s = Simulation(caseid = 'bl2a')
# If the simulation is not in the current directory,
s = Simulation(caseid = 'bl2a', sim_dir = 'bl')
# Simulation will try to load the grid. The gridfile is taken from an output file.
# It searches for that file in ., ../, ../grid, ../../grid and the directory from the full path.
# If you have it somewhere else, provide that directory with:
s = Simulation(grid_dir = '/my/grid/path')
#ACCESS OUTPUT
#=============
# Get the last output:
o = s.getLast()
# Get at time:
o = s.getAtTime(0.5)
# Get at iteration:
o = s.getAtIter(2549)
# Output will load all fields and create all Field instances.
#ACCESS FIELD DATA
#=================
# Fields are named after their field ID (T,P,S,v,...)
# If output detects a vector (like v) it automatically splits it into magnitude: adds "mag"; radial component: adds "r"
# The raw array with the according positions (n = amount of cells):
pos = o.grid.coords # [n, 3] array
temperature = o.temperature.data # [n, 1] array
temperature = o.temperature.data.squeeze() # [n] array
# formatted data (only 2D BOX/CYL or 3D BOX)
temperature = o.temperature.formatted_data # [n_x, n_y] array
imshow(temperature, origin="lower")
# vector magnitude:
vel_mag = o.velocitymag.data
# Cartesian component of vector
v_x = o.velocity.data[:,0]
v_y = o.velocity.data[:,1]
# Return data for a specific shell:
temperature_shell_5 = o.temperature.getShellData(5)
# Return a profile (radial averaged)
# profile has for each shell: [[radius, min, mean, max], ... nShells]
t_prof = o.temperature.getProfile()
# Get volume averaged mean of field
mean_t = o.temperature.getMean()
# Get RMS velocity
v_rms = o.velocitymag.getMean(order=2)
#ACCESS GEOMETRY
#===============
# access grid via Simulation or Output. s.grid == o.grid (reference)
s.grid.nShells
s.grid.nCells
s.grid.coords
s.grid.coordsSph
s.grid.volumes
s.grid.innerRadius
s.grid.outerRadius
s.grid.resolution # mean distance between cells
s.grid.shellOffset
s.grid.shellCoords
s.grid.shellCoordsSph
s.grid.shellRadius # or height if its a box
Or use s.grid.get_infos() directly to get a summary of the grid properties.
#GRAPHICAL OUTPUT
#================
# Other methods are directly meant for graphic processing.
# Check out the notebooks.
#TIME SERIES
#===========
stats = s.getStats()
# See timeseries notebook on how to use
#PARAMETER STUDIES
#=================
# In case a parameter study is present in the current path just use:
ps = ParameterStudy()
# A dict with all available combinations:
ps.cases
# The entries:
ps.entries
#ADD FIELD DATA TO OUTPUT
#========================
# In case you want to add a constructed field form post-processing to an output to visualize it with ParaView:
o.addScalar("L") # creates a new scalar field containing zeros, equiv. addVector("m")
o.L.data = o.temperature.data + 1
o.save() # Overwrites original file!
o.save(filename="new_dir/" + o.filename) # ... to another file
# - Only manipulate .data, do not touch raw_data !
# - Remember convention: Uppercase == Scalar, Lowercase == Vector
# - To avoid ParaView conflicts you should add the new field to all outputs of a sim
The Direct interface (not populated to v3 yet)
This interface is available via the GAIA module's Direct() class. It loads libgaia.so in the current directory and allows control in between time-steps. A few things to note here:
- MPI version(s) do not work yet. MUMPS or CUDA (w/OMP) works.
- When building GAIA, a
libgaia.sois always created with the executable. This is what the Direct() class needs. - Calling order is important here!
- First call
init1(), this will setup theiniinstance. - Use any number of
iniLoad()orsetParameter()calls. - Call
init2(). This is Gaia's C++init()call and will load / create Grids and prepare the Simulation. - Now you can for the first time call
getState() - Call
doTimestep(), it returns the next delta time. Zero means MaxTime is reached.
- First call
- Look at the
gaia_test.pywithin the C++ code for an example
getState() and God-Mode
Be careful about the contents of the returned dictionary, these are references to the Simulation's raw arrays, not copies!
Means you can interact with the simulation in any way. You can also throw in some setParameter() calls. Careful, many mods do create a copy on init and never read them again.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fvsparcs-0.1.0.tar.gz.
File metadata
- Download URL: fvsparcs-0.1.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c08bacc99efc5284a7fb2801ddda770ca5ac1048a13399eb363bcdca71167fb
|
|
| MD5 |
aa661e1e559cd28119d6546ef392f5cf
|
|
| BLAKE2b-256 |
2420f67ff32fb5bf25e782174581b9529a875259d5b3bb845fa3044d15a5a34e
|
File details
Details for the file fvsparcs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fvsparcs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
255d582856f6c01217b11ef3d38488b9ec2ae037936e18df0e49398ef6dc77b5
|
|
| MD5 |
55847d1c3732d4e2dfa3866a7e47f6cd
|
|
| BLAKE2b-256 |
73fc0db96c88f0068c4dfbdacc6c5483d54f79802e6f8d85d345bf9145b8843f
|