coconut_tools.how_to_read_output¶
This module provides functions to read and process simulation outputs from the COCONUT code. It includes conversion of CFmesh files and VTU files into structured data and spherical coordinates suitable for heliospheric modeling and visualization.
Functions
|
Read and parse a CFmesh output file from COCONUT simulations. |
|
Convert a VTU file from COCONUT into spherical coordinates and physical quantities. |
|
Parse structure of CFmesh file and extract section indices and metadata. |
- coconut_tools.how_to_read_output.read_cfmesh_file(input_cfmesh)[source]¶
Read and parse a CFmesh output file from COCONUT simulations.
- Parameters:
input_cfmesh (str) – Path to the CFmesh input file.
- Returns:
- Dictionary containing parsed mesh and physical quantities:
’connectivity’: element connectivity array
’coordinates’: node coordinates array
’cell_centers’: computed center positions for each element
’B’: magnetic field components (Bx, By, Bz)
’V’: velocity components (Vx, Vy, Vz)
’rho’: density (cm^-3)
’P’: pressure (Pa)
’T’: temperature (K)
’r’: radial distances of cell centers
- Return type:
dict
- coconut_tools.how_to_read_output.read_vtu_to_spherical_vectors(input_vtu)[source]¶
Convert a VTU file from COCONUT into spherical coordinates and physical quantities.
- Parameters:
input_vtu (str) – Path to the VTU file to read.
- Returns:
- Dictionary of spherical components and coordinates including:
’r’: radial distances
’theta’: polar angle (rad)
’phi’: azimuthal angle (rad)
’phi2pi’: azimuth in [0, 2pi]
’vr’: radial velocity
’vclt’: colatitudinal velocity
’vlon’: longitudinal velocity
’br’: radial magnetic field
’bclt’: colatitudinal magnetic field
’blon’: longitudinal magnetic field
’rho’: density
’p’: pressure
- Return type:
dict
Notes
- Normalization constants (if needed):
vrkms = vr * 480248.0 # from code units to km/s vpkms = vlon * 480248.0 # from code units to km/s vtkms = vclt * 480248.0 # from code units to km/s
brt = br * 2.2e-4 # from code units to Tesla blont = blon * 2.2e-4 # from code units to Tesla bclt = bclt * 2.2e-4 # from code units to Tesla
tk = p / rho * 1.7756e7 # from code units to Kelvin nsi = rho * 1.0e14 # from code units to m3
- coconut_tools.how_to_read_output.readstruct(lines)[source]¶
Parse structure of CFmesh file and extract section indices and metadata.
- Parameters:
lines (List[str]) – List of lines from the CFmesh file.
- Returns:
idx0 (int): Index where element connectivity list starts.
idx1 (int): Index where node list starts.
idx2 (int): Index where state list starts.
idx3 (int): Index where Outlet section starts.
nbelements (int): Number of elements.
nend (int): Number of “!END” markers.
comment (List[List[int, str]]): List of all comment lines with their indices.
- Return type:
Tuple containing