Skip to content

Conversation

@taylorbrown75
Copy link
Collaborator

Added ability to import/export simulation data to json.
Added unit tests, and end to end testing of json functionality.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds JSON import/export functionality to SimulationData, enabling serialization and deserialization of simulation configurations. The implementation includes comprehensive unit tests covering round-trip conversion, precision handling, edge cases, and error scenarios.

Key Changes:

  • Added JSON serialization/deserialization support for all simulation data structures (elements, surfaces, apertures, optical properties, ray sources)
  • Implemented import_json_file() and export_json_file() methods on SimulationData
  • Created extensive test suite with 8 test cases covering various scenarios including round-trip conversion, large field comparison, precision validation, empty cases, and error handling

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 33 comments.

Show a summary per file
File Description
google-tests/unit-tests/simulation_runner/native_runner/calculator_factory_test.cpp Added write_json override to UnknownSurface test fixture
google-tests/unit-tests/simulation_data/file_io_test.cpp New test file with comprehensive JSON I/O tests including round-trip, precision, validation, and error handling
google-tests/unit-tests/simulation_data/aperture_test.cpp Added write_json implementation to TestAperture fixture
google-tests/unit-tests/simulation_data/CMakeLists.txt Updated build configuration to include new test file and required dependencies
coretrace/simulation_data/surface.hpp Added write_json virtual method and JSON constructors to all surface types; added SurfaceTypeMap
coretrace/simulation_data/surface.cpp Implemented JSON serialization/deserialization for Cone, Cylinder, Flat, Parabola, and Sphere surfaces
coretrace/simulation_data/stage_element.hpp Added JSON constructor and write_json method declarations
coretrace/simulation_data/stage_element.cpp Implemented JSON import/export for stage elements with validation
coretrace/simulation_data/single_element.hpp Added JSON constructor and write_json method declarations
coretrace/simulation_data/single_element.cpp Implemented JSON serialization for single elements including aperture, surface, and optical properties
coretrace/simulation_data/simulation_data.hpp Added public API methods for JSON import/export and ray source iteration
coretrace/simulation_data/simulation_data.cpp Delegated JSON I/O methods to simdata_io functions
coretrace/simulation_data/simdata_io.hpp Added write_json_file, load_json_file functions and get_enum_from_string template utility
coretrace/simulation_data/simdata_io.cpp Core JSON serialization logic for entire simulation including parameters, sources, and elements
coretrace/simulation_data/ray_source.hpp Added UNKNOWN enum value and SunShapeMap for string conversion
coretrace/simulation_data/optical_properties.hpp Added JSON constructor and write_json method; added InteractionTypeMap
coretrace/simulation_data/optical_properties.cpp Implemented JSON serialization for optical properties
coretrace/simulation_data/json_helpers.hpp New utility header for JSON value extraction with NaN handling
coretrace/simulation_data/error_distributions.hpp Added UNKNOWN enum value and DistributionTypeMap
coretrace/simulation_data/element.hpp Added pure virtual write_json methods and is_top_level check to Element interface
coretrace/simulation_data/element.cpp Implemented JSON constructor and common JSON serialization for ElementBase
coretrace/simulation_data/composite_element.hpp Added JSON constructor and write_json method declarations
coretrace/simulation_data/composite_element.cpp Implemented recursive JSON serialization for composite elements
coretrace/simulation_data/aperture.hpp Added write_json virtual method and JSON constructors for all aperture types; added ApertureTypeMap
coretrace/simulation_data/aperture.cpp Implemented JSON serialization/deserialization for all aperture types
coretrace/simulation_data/CMakeLists.txt Added nlohmann_json library dependency via FetchContent

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@jmaack24 jmaack24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Looks really good to me. I left a few notes on things.

taylorbrown75 and others added 13 commits November 21, 2025 09:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
taylorbrown75 and others added 6 commits November 21, 2025 10:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@NREL NREL deleted a comment from Copilot AI Nov 21, 2025
@taylorbrown75 taylorbrown75 merged commit a73a760 into develop Nov 21, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants