# Solving Projects Use {func}`solve ` to run one {term}`project`, repeat one project with {term}`batched project keys`, or run an {term}`ordered project bundle`. ```python import jcmsuite result = jcmsuite.solve("project.jcmp") ``` ## What {func}`solve ` Returns The project input and `keys=` argument determine whether {func}`solve ` returns results for one project, a batch, or a project bundle. See the [Result API](../../reference/results.md) for the exact return types. | {term}`Project ` input | `keys=` input | What you get | | ------------------------------- | -------------------------------- | ------------------------------------------ | | One {term}`project` | None or one {term}`project keys` | Results for one project | | One {term}`project` | {term}`Batched project keys` | Results for a batch of project keys | | {term}`Ordered project bundle` | None or one {term}`project keys` | Results for ordered project bundle | | {term}`Ordered project bundle` | {term}`Batched project keys` | 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](batched.md). When one project supplies inputs for another project, use an ordered project bundle. See [Ordered Project Bundles](bundles.md). Pass `mode="postprocess"` to run only declared postprocesses with accessible saved {term}`fieldbags ` and without a Resultbag. ## Solve One Project Use one project with one set of project keys, or with no project keys: ```python import jcmsuite result = jcmsuite.solve("project.jcmp") ``` The call waits for completion and returns a {class}`SolveResult `. The project can be a rendered `.jcmp` file or a templated `.jcmpt` file. Pass project keys to `keys=` when the project uses templating: ```python result = jcmsuite.solve( "project.jcmp", keys={"radius": 0.5}, ) ``` `keys=` is keyword-only. One set of project keys produces one {class}`SolveResult `. ## Select A Working Directory By default, {func}`solve ` runs from the project directory. Pass `working_dir=` to stage the project inputs and run the solve in another directory: ```python 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 {term}`JCMT pattern` to prefer suffixed {term}`project support files `: ```python 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 {class}`Resultbag ` when matching stored results must be reused: ```python 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 {term}`Resultbag entry `. More information about Resultbags can be found in the [Resultbag section](../../resultbag/index.md). ## Solve Pages ```{toctree} :maxdepth: 1 :titlesonly: :caption: Solve Pages batched bundles ``` ## Next Steps Use [Working With Results](../../results/index.md) to inspect the returned result data. See these complete runnable tutorials: - [Solve one project](../../tutorials/core/solve/01_single_solve/01_default.md). - [Solve with a JCMT pattern](../../tutorials/core/solve/01_single_solve/02_suffix_pattern.md). - [Solve in a working directory](../../tutorials/core/solve/01_single_solve/03_working_dir.md). - [Solve a templated project](../../tutorials/core/solve/01_single_solve/04_template.md). - [Reuse results with a Resultbag](../../tutorials/core/solve/01_single_solve/05_resultbag.md).