HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
|
Functions | |
get_available_error_types () | |
validate_error_selection (selected_errors) | |
parse_timehistory_file (filename) | |
compute_energy_error (file_data) | |
extract_error_arrays (parsed_files) | |
calculate_convergence_rate (mesh_sizes, errors) | |
extract_simulation_info (parsed_files) | |
create_convergence_plot (error_arrays, sim_info, selected_error_types, output_file='convergence_plot.png') | |
generate_latex_plot (error_arrays, sim_info, selected_error_types, output_file='convergence_plot.tex') | |
generate_latex_table (error_arrays, sim_info, selected_error_types, output_file='convergence_table.tex') | |
main () | |
Variables | |
dict | ALL_ERROR_TYPES |
Convergence Analysis Script for HHO-NSA Simulation Data - Enhanced Version with Error Selection Focus: Read files, extract error quantities, and generate plots/tables for k=0 simulations Only considers energy-related errors: Energy, L2density, L2velocity, UPWdensity, H1velocity NEW FEATURE: Ability to select which error types to include in plots and tables Output options: - PNG/PDF plots (matplotlib) - LaTeX table (for inclusion in documents) - LaTeX plot (pgfplots, can be compiled standalone or included)
convergence_analysis.calculate_convergence_rate | ( | mesh_sizes, | |
errors | |||
) |
Calculate convergence rate using least squares fit on log-log data. Parameters: mesh_sizes (array): Array of mesh sizes errors (array): Array of corresponding errors Returns: tuple: (rate, constant) where rate is the convergence rate and constant is the fitting constant
convergence_analysis.compute_energy_error | ( | file_data | ) |
Compute the energy error norm and its components for a single simulation file. Energy = sqrt(L2density + L2velocity + UPWdensity + H1velocity) where: - L2density = max(L2_density_errors^2) over all time steps - L2velocity = max(L2_velocity_errors^2) over all time steps - UPWdensity = sum over time steps of dt * upwind_density_errors^2 - H1velocity = sum over time steps of dt * viscosity * h1_velocity_errors^2 Parameters: file_data (dict): Dictionary from parse_timehistory_file containing all_data Returns: dict: Dictionary containing all energy components and total energy
convergence_analysis.create_convergence_plot | ( | error_arrays, | |
sim_info, | |||
selected_error_types, | |||
output_file = 'convergence_plot.png' |
|||
) |
Create convergence plot with selected energy error types only. Parameters: error_arrays (dict): Dictionary containing error arrays sim_info (dict): Simulation info for title selected_error_types (dict): Dictionary of selected error types to plot output_file (str): Output filename for the plot
convergence_analysis.extract_error_arrays | ( | parsed_files | ) |
Extract arrays of relevant errors from multiple parsed files. Since we only work with k=0, no need to group by degree. Only extracts energy-related errors. Parameters: parsed_files (list): List of dictionaries from parse_timehistory_file Returns: dict: Dictionary containing error arrays
convergence_analysis.extract_simulation_info | ( | parsed_files | ) |
Extract simulation info for titles (mesh type and time step). Parameters: parsed_files (list): List of parsed file data Returns: dict: Dictionary with mesh_type and time_step
convergence_analysis.generate_latex_plot | ( | error_arrays, | |
sim_info, | |||
selected_error_types, | |||
output_file = 'convergence_plot.tex' |
|||
) |
Generate LaTeX document with pgfplots for the convergence plot. Parameters: error_arrays (dict): Dictionary containing error arrays sim_info (dict): Simulation info for title selected_error_types (dict): Dictionary of selected error types to plot output_file (str): Output filename for the LaTeX plot
convergence_analysis.generate_latex_table | ( | error_arrays, | |
sim_info, | |||
selected_error_types, | |||
output_file = 'convergence_table.tex' |
|||
) |
Generate LaTeX table with convergence rates and error values. Only includes selected energy-related errors. Parameters: error_arrays (dict): Dictionary containing error arrays sim_info (dict): Simulation info for title selected_error_types (dict): Dictionary of selected error types to include output_file (str): Output filename for the LaTeX table
convergence_analysis.get_available_error_types | ( | ) |
Return list of available error type names for user selection.
convergence_analysis.main | ( | ) |
Main function with post-treatment options for k=0 simulations.
convergence_analysis.parse_timehistory_file | ( | filename | ) |
Parse a single timehistory file and extract relevant quantities. Parameters: filename (str): Path to the timehistory file Returns: dict: Dictionary containing extracted data
convergence_analysis.validate_error_selection | ( | selected_errors | ) |
Validate user's error type selection. Parameters: selected_errors (list or None): List of user-selected error type names, or None if not specified Returns: dict: Dictionary of valid error types to use
dict convergence_analysis.ALL_ERROR_TYPES |