SolveResult Access

Use this page when you have a SolveResult and want to select, inspect, and export its result data.

SolveResult Data

SolveResult provides these types of result data:

project_file

Shows which project file was used.

print(results.project_file)
# /home/.../mie2D.jcmp

log

Access logs from the solve call through the log attribute. The value is a SolveExecutionLog.

print(results.log)
# SolveExecutionLog(
#     backend='local',
#     stdout='...',
#     stderr='',
#     return_code=0,
#     streamed_to_console=True,
# )

Use the log.stdout attribute to access messages written to the terminal.

Access the solve return code through log.return_code.

file

Shows which fieldbag file is used for postprocessing.

print(results.file)
# /home/.../fieldbag.jcm

keys

When the project uses templating, these keys show the template parameters used to create the result. Otherwise, results.keys is None.

print(results.keys)
# SolveKeys(
#   preview=
#   radius
#   0.5
# )

costs

This contains solve-cost data such as wall time, CPU time, and memory use.

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 result.costs.header and can be exported separately.

print(results.costs.header)
# ComputationalCostsHeader(
#   preview=
#   AccumulatedCPUTime  AccumulatedTotalTime
#   4.838694            1.02428176
# )

eigenvalues

This contains eigenvalues from a solved resonance project. It is None when no eigenvalues are available, for example for a scattering project.

print(results.eigenvalues)
# Eigenvalues(
#   preview=
#     title          effective_refractive_index
#   0 'Eigenvalues'  np.complex128(1.247284605283855+3.288...
#   ...
# )

postprocesses

This collection contains the project’s postprocesses. It supports selection but not export. To list the postprocesses, use result.postprocesses.titles().

Select a postprocess for further analysis, for example with result.postprocesses[0]. The available processing and export methods depend on the selected postprocess.

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.

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:

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 to_powerflux() to calculate power-flux density. The method returns another PostprocessRecord:

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 header:

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 fields property:

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. Use is_field_export() to check whether a postprocess contains field data.

SolveResult Pages