.. _python_api_fork:

.. currentmodule:: flow360

*****************
Fork a Case
*****************

This example demonstrates the procedure for continue from an existing simulation case stored in the cloud.
It shows how to retrieve a parent case, modify specific simulation parameters (in this instance, the angle of attack),
and subsequently initiate a new case based on these adjusted parameters while referencing the original case.

.. code-block:: python

    import flow360 as fl

    project = fl.Project.from_cloud("PROJECT_ID_HERE")

    parent_case = fl.Case(id="PARENT_CASE_ID_HERE")

    param: fl.SimulationParams = parent_case.params

    # fork with new angle of attack being 1.23 degrees
    param.operating_condition.alpha = 1.23 * fl.u.deg

    project.run_case(params=param, fork_from=parent_case, name="Forked case with new alpha")

Notes
-----

- Existing projects and cases are accessed via ``Project.from_cloud`` and ``Case`` respectively.
- Simulation parameters are retrieved from the parent case using ``parent_case.params`` and subsequently modified.
- The ``fork_from`` argument within ``project.run_case`` specifies the parent case from which the new simulation is derived.
