cosapp.drivers.runsinglecase

Functions

get_target_varnames(problem)

Extract the names of all variables involved in targets within problem.

Classes

RunSingleCase(name[, owner])

Set new boundary conditions and equations on the system.

class cosapp.drivers.runsinglecase.RunSingleCase(name: str, owner: System | None = None, **kwargs)[source]

Bases: IterativeCase

Set new boundary conditions and equations on the system.

By default, it has a RunOnce driver as child to run the system.

case_values

List of requested variable assignments to set up the case

Type:

List[AssignString]

initial_values

List of variables to set with the values to set and associated indices selection

Type:

Dict[str, Tuple[Any, Optional[numpy.ndarray]]]

Parameters:
  • name (str) – Name of the driver

  • owner (System, optional) – System to which driver belongs; defaults to None

  • **kwargs (Any) – Keyword arguments will be used to set driver options

add_equation(equation: str | Iterable[dict | str], *args, **kwargs) MathematicalProblem[source]

Add local equation(s). Shortcut to self.offdesign.add_equation(equation, *args, **kwargs).

More details in MathematicalProblem.add_equation.

Parameters:
  • equation (-) – Equation or list of equations to add

  • *args (-) –

  • **kwargs (Forwarded to MathematicalProblem.add_equation)

Returns:

The modified mathematical problem

Return type:

MathematicalProblem

add_offdesign_problem(offdesign: MathematicalProblem) MathematicalProblem[source]

Add outer off-design problem to inner problem.

Returns:

  • MathematicalProblem

    The modified mathematical problem

add_target(expression: str | Iterable[str], *args, **kwargs) MathematicalProblem[source]

Add deferred equation(s) on current point. Shortcut to self.offdesign.add_target(expression, *args, **kwargs).

More details in MathematicalProblem.add_target.

Parameters:
  • expression (-) – Targetted expression

  • *args (-) –

  • **kwargs (Forwarded to MathematicalProblem.add_target)

Returns:

The modified mathematical problem

Return type:

MathematicalProblem

add_unknown(name: str | Iterable[dict | str], *args, **kwargs) MathematicalProblem[source]

Add local unknown(s). Shortcut to self.offdesign.add_unknown(name, *args, **kwargs).

More details in MathematicalProblem.add_unknown.

Parameters:
  • name (-) – Name of the variable or list of variables to add

  • *args (-) –

  • **kwargs (Forwarded to MathematicalProblem.add_unknown)

Returns:

The modified mathematical problem

Return type:

MathematicalProblem

add_value(variable: str, value: Any) None[source]

Add a single variable to list of case values.

The variable can be contextual child1.port2.var. The only rule is that it should belong to the owner System of this driver or any of its descendants.

Parameters:
  • variable (str) – Name of the variable

  • value (Any) – Value to be used.

Examples

>>> driver.add_value('myvar', 42)
add_values(modifications: Dict[str, Any]) None[source]

Add a set of variables to the list of case values, from a dictionary of the kind {‘variable1’: value1, …}

The variable can be contextual child1.port2.var. The only rule is that it should belong to the owner System of this driver or any of its descendants.

Parameters:

modifications (Dict[str, Any]) – Dictionary of (variable name, value)

Examples

>>> driver.add_values({'myvar': 42, 'port.dummy': 'banana'})
apply_values() None[source]
property case_values: List[AssignString]
clean_run()[source]

Method called once after any simulation.

clear_values()[source]
property design: MathematicalProblem

Design problem solved for case

Type:

MathematicalProblem

extend(problem: MathematicalProblem) MathematicalProblem[source]

Extend local problem. Shortcut to self.offdesign.extend(problem).

Parameters:

problem (-)

Returns:

The extended mathematical problem

Return type:

MathematicalProblem

get_problem() MathematicalProblem[source]

Returns the full mathematical for the case.

Returns:

The full mathematical problem to solve for the case

Return type:

MathematicalProblem

merged_problem(copy=True) MathematicalProblem[source]
property offdesign: MathematicalProblem

Local problem solved for case

Type:

MathematicalProblem

problem: MathematicalProblem | None
property processed_problems: DesignProblemHandler

design/off-design problem handler

Type:

DesignProblemHandler

reset_problem() None[source]

Reset design and off-design problems defined on case.

set_values(modifications: Dict[str, Any]) None[source]

Enter the set of variables defining the case, from a dictionary of the kind {‘variable1’: value1, …} Note: will erase all previously defined values. Use ‘add_values’ to append new case values.

The variable can be contextual child1.port2.var. The only rule is that it should belong to the owner System of this driver or any of its descendants.

Parameters:

modifications (Dict[str, Any]) – Dictionary of (variable name, value)

Examples

>>> driver.set_values({'myvar': 42, 'port.dummy': 'banana'})
setup_run()[source]

Method called once before starting any simulation.

cosapp.drivers.runsinglecase.get_target_varnames(problem: MathematicalProblem) Set[str][source]

Extract the names of all variables involved in targets within problem.

Parameters:

problem [MathematicalProblem]

Returns:

set[str]: set of variable names.