Solving Projects
Use solve to run one project, repeat one project with
batched project keys, or run an ordered project bundle.
import jcmsuite
result = jcmsuite.solve("project.jcmp")
What solve Returns
The project input and keys= argument determine whether solve returns
results for one project, a batch, or a project bundle. See the Result
API for the exact return types.
Project input |
|
What you get |
|---|---|---|
One project |
None or one project keys |
Results for one project |
One project |
Results for a batch of project keys |
|
None or one project keys |
Results for ordered project bundle |
|
Batched results for ordered project bundle |
When you want to solve the same project file for different project keys, use batched project keys. See Batched Solves.
When one project supplies inputs for another project, use an ordered project bundle. See Ordered Project Bundles.
Pass mode="postprocess" to run only declared postprocesses with accessible
saved fieldbags and without a Resultbag.
Solve One Project
Use one project with one set of project keys, or with no project keys:
import jcmsuite
result = jcmsuite.solve("project.jcmp")
The call waits for completion and returns a SolveResult. The project can be a
rendered .jcmp file or a templated .jcmpt file. Pass project keys to keys= when the
project uses templating:
result = jcmsuite.solve(
"project.jcmp",
keys={"radius": 0.5},
)
keys= is keyword-only. One set of project keys produces one SolveResult.
Select A Working Directory
By default, solve runs from the project directory. Pass working_dir= to stage the
project inputs and run the solve in another directory:
result = jcmsuite.solve(
"examples/mie2d/project.jcmp",
working_dir="build/mie2d",
)
Set temporary=True when the source project directory must not receive solve result data and
you do not need to retain the staged project files. An explicit working_dir takes
precedence over temporary=True.
Select Project Support Files
Use a JCMT pattern to prefer suffixed project support files:
result = jcmsuite.solve(
"project.jcmp",
jcmt_pattern="fine",
)
This selection prefers files such as layout.fine.jcm and layout.fine.jcmt before
layout.jcm and layout.jcmt. The JCMT pattern does not select another project file.
Reuse Stored Results
Pass a Resultbag when matching stored results must be reused:
from jcmsuite.results import Resultbag
with Resultbag("results.jcmrb") as resultbag:
result = jcmsuite.solve(
"project.jcmp",
keys={"radius": 0.5},
resultbag=resultbag,
)
Set recompute=True to run the project again instead of reusing a matching
Resultbag entry.
More information about Resultbags can be found in the Resultbag section.
Solve Pages
Solve Pages
Next Steps
Use Working With Results to inspect the returned result data.
See these complete runnable tutorials: