# SolveResult Access Use this page when you have a {class}`SolveResult ` and want to select, inspect, and export its result data. ## SolveResult Data {class}`SolveResult ` provides these types of result data: - {attr}`project_file `: the solved project file. - {attr}`log `: access to the logs associated with the solve call. - {attr}`file `: the fieldbag file used for eigenvalue and postprocess calculations. - {attr}`keys `: metadata for the {term}`project keys`. - {attr}`costs `: tabular cost data. - {attr}`eigenvalues `: tabular eigenvalue data. - {attr}`postprocesses `: a collection of postprocesses. ### {attr}`project_file ` Shows which project file was used. ```python print(results.project_file) # /home/.../mie2D.jcmp ``` ### {attr}`log ` Access logs from the solve call through the {attr}`log ` attribute. The value is a {class}`SolveExecutionLog `. ```python print(results.log) # SolveExecutionLog( # backend='local', # stdout='...', # stderr='', # return_code=0, # streamed_to_console=True, # ) ``` Use the {attr}`log.stdout ` attribute to access messages written to the terminal. Access the solve return code through {attr}`log.return_code `. ### {attr}`file ` Shows which fieldbag file is used for postprocessing. ```python print(results.file) # /home/.../fieldbag.jcm ``` ### {attr}`keys ` When the project uses templating, these keys show the template parameters used to create the result. Otherwise, {attr}`results.keys ` is `None`. ```python print(results.keys) # SolveKeys( # preview= # radius # 0.5 # ) ``` ### {attr}`costs ` This contains solve-cost data such as wall time, CPU time, and memory use. ```python print(results.costs) # ComputationalCosts( # preview= # title Level Unknowns CpuTime # 0 'ComputationalCosts' np.int32(0) np.int32(47781) np.float64(4.072316) # ... # ) ``` An additional metadata header is available via {attr}`result.costs.header ` and can be exported separately. ```python print(results.costs.header) # ComputationalCostsHeader( # preview= # AccumulatedCPUTime AccumulatedTotalTime # 4.838694 1.02428176 # ) ``` ### {attr}`eigenvalues ` This contains eigenvalues from a solved resonance project. It is `None` when no eigenvalues are available, for example for a scattering project. ```python print(results.eigenvalues) # Eigenvalues( # preview= # title effective_refractive_index # 0 'Eigenvalues' np.complex128(1.247284605283855+3.288... # ... # ) ``` ### {attr}`postprocesses ` This collection contains the project's postprocesses. It supports selection but not export. To list the postprocesses, use {meth}`result.postprocesses.titles() `. Select a postprocess for further analysis, for example with {attr}`result.postprocesses[0] `. The available processing and export methods depend on the selected postprocess. ```python print(results.postprocesses) # PostprocessCollection( # index title status # 0 ElectromagneticFieldEnergyFlux available # 1 ElectricFieldStrength_PropagatingFour... available # 2 fieldbag_cartesian available # ) print(results.postprocesses.titles()) # ('ElectromagneticFieldEnergyFlux', 'ElectricFieldStrength_PropagatingFourierCoefficients', # 'fieldbag_cartesian') ``` Postprocesses can be divided into tabular-data postprocesses and field export postprocesses. #### Tabular data The first two postprocesses contain tabular data. ```python print(results.postprocesses[0]) # PostprocessRecord( # source_file: /home/.../energyflux_scattered.jcm # title: ElectromagneticFieldEnergyFlux # status: available # preview: # title DomainIdFirst DomainIdSecond # 0 'ElectromagneticFieldEnergyFlux' np.int32(1) np.int32(1) # ... # ) ``` ##### Fourier table data The second postprocess contains a Fourier table: ```python print(results.postprocesses[1]) # PostprocessRecord( # source_file: /home//fc.jcm # title: ElectricFieldStrength_PropagatingFourierCoefficients # status: available # preview: # title K # 0 'ElectricFieldStrength_PropagatingFou... array([-11309733.55292325, # 1 'ElectricFieldStrength_PropagatingFou... array([-10995574.28756427, # 2 'ElectricFieldStrength_PropagatingFou... array([-10681415.02220529, # 3 'ElectricFieldStrength_PropagatingFou... array([-10367255.75684631, # 4 'ElectricFieldStrength_PropagatingFou... array([-10053096.49148733, # ... # ) ``` Use {meth}`to_powerflux() ` to calculate power-flux density. The method returns another {class}`PostprocessRecord `: ```python print(results.postprocesses[1].to_powerflux()) # PostprocessRecord( # source_file: /home//fc.jcm # title: PowerFluxDensity_PropagatingFourierCoefficients # status: available # preview: # title PowerFluxDensity.0.0 # 0 'PowerFluxDensity_PropagatingFourierC... np.float64(-1.3023754883263514e-05) # 1 'PowerFluxDensity_PropagatingFourierC... np.float64(-3.42953682342973e-07) # 2 'PowerFluxDensity_PropagatingFourierC... np.float64(-6.738931587085882e-08) # 3 'PowerFluxDensity_PropagatingFourierC... np.float64(-2.7361546369239474e-07) # 4 'PowerFluxDensity_PropagatingFourierC... np.float64(-3.5626217895385513e-07) # ... # ) ``` ##### Headers in tabular postprocesses Tabular postprocesses may contain a {attr}`header `: ```python print(results.postprocesses[1].header) # PostprocessHeader( # preview= # NormalDirection EffectiveSpaceDim IsPeriodic1 IsPeriodic2 NContinuousSpectrumModes # 'Z' 2 0 1 73 # ... # ) ``` #### Field export data The third postprocess contains field export data, available through the {attr}`fields ` property: ```python print(results.postprocesses[2]) # PostprocessRecord( # source_file: /home/.../fieldbag_cartesian.jcm # title: fieldbag_cartesian # status: available # preview: # view: complete # indices: (0, 1) # coordinates: X=(200, 200), Y=(200, 200) # field_shape: (200, 200, 3) # derivatives: () # transforms: () # ) print(results.postprocesses[2].is_field_export()) # True ``` You can transform as well as export field data. See [Field Export Postprocess](field_exports.md). Use {meth}`is_field_export() ` to check whether a postprocess contains field data. ## SolveResult Pages ```{toctree} :maxdepth: 2 :titlesonly: field_exports ``` ## Related Pages - [Batched Results](../batched.md) - [Bundled Results](../bundled.md) - [Data Exporting](../data_exports.md)