Working With Results
Use this section after you create a result with solve, retrieve a
result from a Resultbag, or open an existing result
on disk.
If you still need to create a result, start with Solving
Projects and jcmsuite.solve.
Choose A Result Source
Fresh solve: use the value returned by
jcmsuite.solve.
import jcmsuite
result = jcmsuite.solve("project.jcmp")
Resultbag query: use the stored result from a
Resultbagfile withresultbag.get_results.
import jcmsuite
resultbag = jcmsuite.results.Resultbag("runs.jcmrb")
result = resultbag.get_results({"radius": 0.5})
Existing result: open a project file or result directory with
open.
import jcmsuite
result = jcmsuite.results.open("project_results")
In each situation, you use the returned result in the same way.
Select And Export Result Data
A result provides several types of data through named attributes:
project keys (via
result.keys)costs (via
result.costs)eigenvalues (via
result.eigenvalues)a collection of postprocesses (via
result.postprocesses)
Select result data through one of these attributes. Then use a method from Data
Exporting to export the selected data. The available methods depend on the
data type. For postprocesses, first select one postprocess, for example with
result.postprocesses[0]. Then export
its data.
The supported export methods are:
to_dict(), which exports the data into a dictionary. The deprecatedto_mapping()compatibility name is also available,to_df(), which exports the data into apandasDataFrame,to_xarray(), which exports the data into anxarrayDataTree structure.
For numeric tables and table collections,
inspect solver parameter derivatives through
postprocess.derivatives.
Call keys()
for a table or
keys()
for a table collection to list available parameter names.
Select a first derivative by name, then use its
derivatives collection to select a second
derivative:
table = result.postprocesses[0]
print(table.derivatives.keys())
first = table.derivatives["width_parameter"]
second = first.derivatives["height"]
values = second.to_dict()["ElectricFieldStrength"]
Each selected view keeps the original quantity names and supports the result’s
dictionary, DataFrame, and xarray exports. Table collections also keep their member
names and omit members without the selected derivative. A missing parameter or pair
raises KeyError; it is not replaced with zero. Whole-record exports are unchanged.
See Data Exports for collection exports.
List-Style Access
Use an index in square brackets to select one postprocess, batch entry, or bundled project
result. Index 0 selects the first item:
postprocess = result.postprocesses[0]
entry = batch[0]
project_result = bundle[1]
Use a slice, such as batch[1:4], to select a
range of items from a BatchSolveResult or a daemon
submission. The first number is included and the second number is excluded. The
selected value keeps the documented input order. See the
Result API list-access reference for complete indexing and
slicing behavior.
Results From solve
The project input and keys= input determine whether solve
returns results for one project, a batch, or an ordered project bundle. See Solving
Projects to choose the input form. See the
Result API for the exact return types.
Use Torch Integration when a solve must participate in a PyTorch objective without changing ordinary result navigation.
Use SolveResult Access for results from one project. The guide
contains sections for costs,
eigenvalues, and
postprocesses, as well as
field data and export formats.
Use Batched Results for details about result data that was obtained using a single project file and batched project keys.
Use Bundled Results when an ordered project bundle returns the result, with no project keys, one set of project keys, or batched project keys.