Package: xcompact3d-toolbox
Xcompact3d ToolboxIt is a Python package designed to handle the pre and postprocessing of
the high-order Navier-Stokes solverXCompact3d. It aims to help users and
code developers to build case-specific solutions with a set of tools and
automated processes.The physical and computational parameters are built on top oftraitlets,
a framework that lets Python classes have attributes with type checking, dynamically calculated default values, and ‘on change’ callbacks.
In addition toipywidgetsfor an user friendly interface.Data structure is provided byxarray(seeWhy xarray?), that introduces labels in the form of dimensions, coordinates and attributes on top of rawNumPy-like arrays, which allows for a more intuitive, more concise, and less error-prone developer experience. It integrates tightly withdaskfor parallel computing andhvplotfor interactive data visualization.Finally, Xcompact3d-toolbox is fully integrated with the newSandbox Flow Configuration.
The idea is to easily provide everything that XCompact3d needs from aJupyter Notebook, like initial conditions, solid geometry, boundary conditions, and the parameters (see examples).
It makes life easier for beginners, that can run any new flow configuration without worrying about Fortran and2decomp.
For developers, it works as a rapid prototyping tool, to test concepts and then compare results to validate any future Fortran implementation.Useful linksDocumentation;Changelog;Suggestions for new features and bug report;See what is coming next (Project page);Xcompact3d's repository.InstallationIt is possible to install using pip:pipinstallxcompact3d-toolboxThere are other dependency sets for extra functionality:pipinstallxcompact3d-toolbox[visu]# interactive visualization with hvplot and otherspipinstallxcompact3d-toolbox[doc]# dependencies to build the documentationpipinstallxcompact3d-toolbox[dev]# tools for developmentpipinstallxcompact3d-toolbox[test]# tools for testingpipinstallxcompact3d-toolbox[all]# all the aboveTo install from source, clone de repository:gitclonehttps://github.com/fschuch/xcompact3d_toolbox.gitAnd then install it interactively with pip:cdxcompact3d_toolbox
pipinstall-e.You can install all dependencies as well:pipinstall-e.[all]Now, any change you make at the source code will be available at your local installation, with no need to reinstall the package every time.Try it OnlineClick on any link above to launchBinderand interact with our notebooks in a live environment!ExamplesImporting the package:importxcompact3d_toolboxasx3dLoading the parameters file (both.i3dand.prmare supported, see#7) from the disc:prm=x3d.Parameters(loadfile="input.i3d")prm=x3d.Parameters(loadfile="incompact3d.prm")Specifying how the binary fields from your simulations are named, for instance:If the simulated fields are named likeux-000.bin:prm.dataset.filename_properties.set(separator="-",file_extension=".bin",number_of_digits=3)If the simulated fields are named likeux0000:prm.dataset.filename_properties.set(separator="",file_extension="",number_of_digits=4)There are many ways to load the arrays produced by your numerical simulation, so you can choose what best suits your post-processing application.
All arrays are wrapped intoxarrayobjects, with many useful methods for indexing, comparisons, reshaping and reorganizing, computations and plotting.
See the examples:Load one array from the disc:ux=prm.dataset.load_array("ux-0000.bin")Load the entire time series for a given variable:ux=prm.dataset["ux"]Load all variables from a given snapshot:snapshot=prm.dataset[10]Loop through all snapshots, loading them one by one:fordsinprm.dataset:# compute somethingvort=ds.uy.x3d.first_derivative("x")-ds.ux.x3d.first_derivative("y")# write the results to the discprm.dataset.write(data=vort,file_prefix="w3")Or simply load all snapshots at once (if you have enough memory):ds=prm.dataset[:]It is possible to produce a new xdmf file, so all data can be visualized on any external tool:prm.dataset.write_xdmf()User interface for the parameters with IPywidgets:prm=x3d.ParametersGui()prmCopyright and LicenseAll content is underGPL-3.0 License.