bluemira.equilibria.solve ========================= .. py:module:: bluemira.equilibria.solve .. autoapi-nested-parse:: Picard iteration procedures for equilibria (and their infinite variations) Classes ------- .. autoapisummary:: bluemira.equilibria.solve.DudsonConvergence bluemira.equilibria.solve.JrelConvergence bluemira.equilibria.solve.JeonConvergence bluemira.equilibria.solve.CunninghamConvergence bluemira.equilibria.solve.JsourceConvergence bluemira.equilibria.solve.PicardIterator Module Contents --------------- .. py:class:: DudsonConvergence(limit: float = PSI_REL_TOL) Bases: :py:obj:`ConvergenceCriterion` .. autoapi-inheritance-diagram:: bluemira.equilibria.solve.DudsonConvergence :parts: 1 :private-bases: FreeGS convergence criterion :param limit: The limit at which the convergence criterion is met. .. py:method:: __call__(psi_old: numpy.typing.NDArray[numpy.float64], psi: numpy.typing.NDArray[numpy.float64], i: int, *, print_status: bool = True) -> bool Carry out convergence check. :param psi_old: The value from the previous iteration. :param psi: The value from the current iteration. :param i: The index of the iteration. :param print_status: If True then prints the status of the convergence, by default True. :rtype: True if the convergence criterion is met, else False. .. py:class:: JrelConvergence(limit: float = 0.01) Bases: :py:obj:`ConvergenceCriterion` .. autoapi-inheritance-diagram:: bluemira.equilibria.solve.JrelConvergence :parts: 1 :private-bases: FreeGS convergence criterion :param limit: The limit at which the convergence criterion is met. .. py:attribute:: flag_psi :value: False .. py:method:: __call__(j_old: numpy.typing.NDArray[numpy.float64], j_new: numpy.typing.NDArray[numpy.float64], i: int, *, print_status: bool = True) -> bool Carry out convergence check. :param j_old: The value from the previous iteration. :param j_new: The value from the current iteration. :param i: The index of the iteration. :param print_status: If True then prints the status of the convergence, by default True. :rtype: True if the convergence criterion is met, else False. .. py:class:: JeonConvergence(limit: float = 0.0001) Bases: :py:obj:`ConvergenceCriterion` .. autoapi-inheritance-diagram:: bluemira.equilibria.solve.JeonConvergence :parts: 1 :private-bases: TES convergence criterion :param limit: The limit at which the convergence criterion is met. .. py:method:: __call__(psi_old: numpy.typing.NDArray[numpy.float64], psi: numpy.typing.NDArray[numpy.float64], i: int, *, print_status: bool = True) -> bool Carry out convergence check. :param psi_old: The value from the previous iteration. :param psi: The value from the current iteration. :param i: The index of the iteration. :param print_status: If True then prints the status of the convergence, by default True. :rtype: True if the convergence criterion is met, else False. .. py:class:: CunninghamConvergence(limit: float = 1e-07) Bases: :py:obj:`ConvergenceCriterion` .. autoapi-inheritance-diagram:: bluemira.equilibria.solve.CunninghamConvergence :parts: 1 :private-bases: FIESTA convergence criterion :param limit: The limit at which the convergence criterion is met. .. py:attribute:: flag_psi :value: False .. py:method:: __call__(j_old: numpy.typing.NDArray[numpy.float64], j_new: numpy.typing.NDArray[numpy.float64], i: int, *, print_status: bool = True) -> bool Carry out convergence check. :param j_old: The value from the previous iteration. :param j_new: The value from the current iteration. :param i: The index of the iteration. :param print_status: If True then prints the status of the convergence, by default True. :rtype: True if the convergence criterion is met, else False. .. py:class:: JsourceConvergence(limit: float = 0.0001) Bases: :py:obj:`ConvergenceCriterion` .. autoapi-inheritance-diagram:: bluemira.equilibria.solve.JsourceConvergence :parts: 1 :private-bases: Plasma current source convergence criterion. :param limit: The limit at which the convergence criterion is met. .. py:attribute:: flag_psi :value: False .. py:method:: __call__(j_old: numpy.typing.NDArray[numpy.float64], j_new: numpy.typing.NDArray[numpy.float64], i: int, *, print_status: bool = True) -> bool Carry out convergence check. :param j_old: The value from the previous iteration. :param j_new: The value from the current iteration. :param i: The index of the iteration. :param print_status: If True then prints the status of the convergence, by default True. :rtype: True if the convergence criterion is met, else False. .. py:class:: PicardIterator(eq: bluemira.equilibria.equilibrium.Equilibrium, optimisation_problem: bluemira.equilibria.optimisation.problem.CoilsetOptimisationProblem, diagnostic_plotting: bluemira.equilibria.diagnostics.PicardDiagnosticOptions | None = None, convergence: ConvergenceCriterion | None = None, *, fixed_coils: bool = False, relaxation: float = 0, maxiter: int = 30, keep_history: bool = False, check_constraints: bool = False) A Picard iterative solver. Child classes must provide a __call__ method which carries out the iteration process(es) :param eq: The equilibrium to solve for :param optimisation_problem: The optimisation problem to use when iterating :param convergence: The convergence criterion to use (defaults to Dudson) :param fixed_coils: Whether or not the coil positions are fixed :param relaxation: The relaxation parameter to use between iterations :param maxiter: The maximum number of iterations :param diagnostic_plotting: PicardDiagnosticOptions - dataclass containing plot type or not plot option, whether or not to make a GIF, the path where figures will be saved and the plot name. .. py:attribute:: eq .. py:attribute:: coilset .. py:attribute:: opt_prob .. py:attribute:: fixed_coils :value: False .. py:attribute:: keep_history :value: False .. py:attribute:: check_constraints :value: False .. py:attribute:: relaxation :value: 0 .. py:attribute:: maxiter :value: 30 .. py:attribute:: diagnostic_plotting .. py:attribute:: i :value: 0 .. py:method:: _optimise_coilset() .. py:property:: psi :type: numpy.typing.NDArray[numpy.float64] Get the magnetic flux array. .. py:property:: j_tor :type: numpy.typing.NDArray[numpy.float64] Get the toroidal current density array. .. py:method:: __call__() -> bluemira.equilibria.optimisation.problem.base.CoilsetOptimiserResult The iteration object call handle. :returns: The result .. py:method:: __iter__() -> collections.abc.Iterator Make the class a Python iterator. :rtype: The current instance as an iterator. .. py:method:: __next__() Perform an iteration of the solver. :raises StopIteration: if converged .. py:method:: iterate_once() -> bluemira.equilibria.optimisation.problem.base.CoilsetOptimiserResult Perform a single iteration and handle convergence. :returns: The result :raises StopIteration: if converged .. py:method:: check_converged(*, print_status: bool = True) -> bool Check if the iterator has converged. :param print_status: If True then prints the status of the convergence, by default True. :rtype: True if the convergence criterion is met, else False. .. py:method:: _solve() Solve for this iteration. .. py:method:: _initial_optimise_coilset(**kwargs) .. py:method:: _setup() Initialise psi and toroidal current values. .. py:method:: _teardown() Final clean-up for consistency between psi and jtor. In the case of converged equilibria, slight (artificial) improvement in consistency. In the case of unconverged equilibria, gives a more reasonable understanding of the final state.