static_problem module

static_problem.DEF_TOL = 1e-10
static_problem.DEF_NEWTON_MAXITER = 30
static_problem.DEF_MAX_PAR_TOL = 0.0001
static_problem.DEF_MAX_PAR_REDUCE_FACT = 0.42
class static_problem.StaticProblem(circuit: pyjjasim.josephson_circuit.Circuit, current_sources=0.0, external_flux=0.0, vortex_configuration=0, current_phase_relation=<static_problem.DefaultCPR object>)[source]

Define a static josephson junction array problem.

Parameters
circuitCircuit

Circuit on which the problem is based.

current_sources=0.0(Nj,) ndarray or scalar

Current sources at each junction in circuit (abbreviated Is). If scalar the same value is used for all junctions.

external_flux=0.0(Nf,) ndarray or scalar

external_flux, or normalized external magnetic flux, through each face in circuit (abbreviated f). If scalar the same value is used for all faces.

vortex_configuration=0(Nf,) ndarray or scalar

Target vorticity at each face in circuit (abbreviated n). If scalar the same value is used for all faces.

current_phase_relation=DefaultCPR()CurrentPhaseRelation

Current-phase relation used to do computations on problem.

Notes

  • All physical quantities are dimensionless. See the UserManual (on github) for how all quantities are normalized.

  • It is assumed each junction has a current source, see user manual (on github) for diagram of junction. To omit the sources in particular junctions set the respective values to zero.

  • To use a node-based souce current (represented as an (Nn,) array Is_node with current in/e-jected at each node), convert it to a junction-based source with Is = node_to_junction_current(circuit, Is_node) and us Is as input for a static problem.

Methods

approximate()

Computes approximate solution.

compute([initial_guess, tol, maxiter, ...])

Compute solution to static_problem using Newton iteration.

compute_external_flux_bounds([...])

Finds extremum values of x such that this problem with f = x * self.external_flux has a valid solution.

compute_maximal_current([initial_guess, ...])

Computes largest source current for which a stable solution exists at the specified target vortex configuration and external_flux, where the source current is assumed to be max_current_factor * self.get_current_sources().

compute_stable_region([angles, ...])

Finds edge of stable region in (f, Is) space for vortex configuration n.

get_circuit()

Returns the circuit.

get_current_phase_relation()

Returns the current-phase relation.

get_current_sources()

Returns the current sources (abbreviated Is).

get_external_flux()

Returns the external_flux (abbreviated f).

get_net_sourced_current()

Gets the sum of all (positive) current injected at nodes to create Is.

get_node_current_sources()

Returns (Nn,) array of currents injected at nodes to create Is.

get_phase_zone()

Returns the phase zone (In all of pyJJAsim phase_zone=0).

get_vortex_configuration()

Returns the vortex configuration.

load(filename)

Load problems created with the .save(filename) method.

new_problem([current_sources, ...])

Makes copy of self with specified modifications.

save(filename)

Store problem in .npy file.

approximate() static_problem.StaticConfiguration[source]

Computes approximate solution.

compute(initial_guess=None, tol=1e-10, maxiter=30, stop_as_residual_increases=True, stop_if_not_target_n=False) tuple[static_problem.StaticConfiguration, int, static_problem.NewtonIterInfo][source]

Compute solution to static_problem using Newton iteration.

Parameters
initial_guess=None(Nj,) array, StaticConfiguration or None

Guess for initial state. If None; uses approximation. If input is array; it must contain values of theta to represent state.

tol=DEF_TOLscalar

Tolerance; is solution if |residual| < tol.

maxiter=DEF_NEWTON_MAXITERint

Maximum number of newton iterations.

stop_if_not_target_n=Falsebool

Iteration stops if n(iter) != n (diverged)

stop_as_residual_increases=Truebool

Iteration stops if error(iter) > error(iter - 3) (diverged).

Returns
configStaticConfiguration

Object containing solution.

statusint
  • 0: converged

  • 1: diverged if error(iter)>0.5 or above reasons.

  • 2: max_iter reached without converging or diverging.

iter_infoNewtonIterInfo

Handle containing information about newton iteration.

compute_external_flux_bounds(initial_guess=None, middle_of_range_guess=None, lambda_tol=0.0001, maxiter=100, require_stability=True, require_vortex_configuration_equals_target=True, compute_parameters=None) tuple[tuple[float, float], tuple[static_problem.StaticConfiguration, static_problem.StaticConfiguration], tuple[static_problem.ParameterOptimizeInfo, static_problem.ParameterOptimizeInfo]][source]

Finds extremum values of x such that this problem with f = x * self.external_flux has a valid solution.

Parameters
middle_of_range_guess=Nonescalar or None.

Value of x somewhere in the middle of range. If None; this is estimated based on vortex configuration.

initial_guess=Nonevalid initial_guess input for StaticProblem.compute()

Initial guess for the algorithm to start at external_flux=middle_of_range_guess * self.external_flux.

Returns
(smallest_x, largest_x)(float, float)

Resulting external_flux range.

(smallest_f_config, largest_f_config)(StaticConfiguration, StaticConfiguration)

StaticConfigurations at bounds of range.

(smallest_f_info, largest_f_info)(ParameterOptimizeInfo, ParameterOptimizeInfo)

ParameterOptimizeInfo objects containing information about the iterations.

compute_maximal_current(initial_guess=None, lambda_tol=0.0001, maxiter=100, require_stability=True, require_vortex_configuration_equals_target=True, compute_parameters=None) tuple[float, static_problem.StaticConfiguration, static_problem.ParameterOptimizeInfo][source]

Computes largest source current for which a stable solution exists at the specified target vortex configuration and external_flux, where the source current is assumed to be max_current_factor * self.get_current_sources().

For parameters see documentation of compute_maximal_parameter()

Returns
max_current_factorfloat

Maximal current factor for which a problem with max_current_factor * Is has a (stable) solution.

out_configStaticConfiguration

StaticConfiguration of state with maximal current.

infoParameterOptimizeInfo

ParameterOptimizeInfo objects containing information about the iterations.

compute_stable_region(angles=array([0., 0.10471976, 0.20943951, 0.31415927, 0.41887902, 0.52359878, 0.62831853, 0.73303829, 0.83775804, 0.9424778, 1.04719755, 1.15191731, 1.25663706, 1.36135682, 1.46607657, 1.57079633, 1.67551608, 1.78023584, 1.88495559, 1.98967535, 2.0943951, 2.19911486, 2.30383461, 2.40855437, 2.51327412, 2.61799388, 2.72271363, 2.82743339, 2.93215314, 3.0368729, 3.14159265, 3.24631241, 3.35103216, 3.45575192, 3.56047167, 3.66519143, 3.76991118, 3.87463094, 3.97935069, 4.08407045, 4.1887902, 4.29350996, 4.39822972, 4.50294947, 4.60766923, 4.71238898, 4.81710874, 4.92182849, 5.02654825, 5.131268, 5.23598776, 5.34070751, 5.44542727, 5.55014702, 5.65486678, 5.75958653, 5.86430629, 5.96902604, 6.0737458, 6.17846555, 6.28318531]), f_middle_of_range_guess=None, start_initial_guess=None, lambda_tol=0.0001, maxiter=100, require_stability=True, require_vortex_configuration_equals_target=True, compute_parameters=None) tuple[numpy.ndarray, numpy.ndarray, typing.List[static_problem.StaticConfiguration], typing.List[static_problem.ParameterOptimizeInfo]][source]

Finds edge of stable region in (f, Is) space for vortex configuration n.

More precisely, returns xf(angle) and xI(angle) such that (xf(angle) * self.f, xI(angle)*self.Is) lies on the boundary of the stable region in (f, Is) space for all specified angles.

For unlisted parameters see documentation of compute_maximal_parameter()

Parameters
angles=np.linspace(0, 2*np.pi, 61)array

Angles at which an extremum in (f, Is) space is searched for.

f_middle_of_range_guess=Nonescalar or None.

Value of xf somewhere in the middle of range. If None; this is estimated based on vortex configuration.

Returns
external_flux(num_angles,) array

Extermum external_flux factor at each angle.

current(num_angles,) array

Extremum sourced current factor at each angle.

all_configslist containing StaticConfiguration

Configurations at extreme value for each angle.

all_infoslist containing ParameterOptimizeInfo

Objects containing information about the iterations at each angle.

get_circuit() pyjjasim.josephson_circuit.Circuit[source]

Returns the circuit.

get_current_phase_relation()[source]

Returns the current-phase relation.

get_current_sources()[source]

Returns the current sources (abbreviated Is).

get_external_flux()[source]

Returns the external_flux (abbreviated f).

get_net_sourced_current()[source]

Gets the sum of all (positive) current injected at nodes to create Is.

get_node_current_sources()[source]

Returns (Nn,) array of currents injected at nodes to create Is.

get_phase_zone()[source]

Returns the phase zone (In all of pyJJAsim phase_zone=0).

get_vortex_configuration()[source]

Returns the vortex configuration.

static load(filename) static_problem.StaticProblem[source]

Load problems created with the .save(filename) method. Returns StaticProblem. Note that the loaded problem will always have the default current-phase-relation.

new_problem(current_sources=None, external_flux=None, vortex_configuration=None, current_phase_relation=None) static_problem.StaticProblem[source]

Makes copy of self with specified modifications.

save(filename)[source]

Store problem in .npy file. Note that the current-phase-relation is not stored!

static_problem.compute_maximal_parameter(problem_function, initial_guess=None, lambda_tol=0.0001, estimated_upper_bound=1.0, maxiter=100, stepsize_reduction_factor=0.42, require_stability=True, require_vortex_configuration_equals_target=True, compute_parameters=None) tuple[float, float, static_problem.StaticConfiguration, static_problem.ParameterOptimizeInfo][source]

Finds the largest value of lambda for which problem_function(lambda) has a stable stationary state.

  • Must be able to find a stable configuration at lambda=0.

  • One can manually specify an initial_guess for lambda=0.

  • returns a lower- and upperbound for lambda. Stops when the difference < lambda_tol * lower_bound

  • furthermore returns config containing the solutions at the lower_bound. Also its accompanied problem has f and Is of lower_bound.

  • Also returns ParameterOptimizeInfo object containing information about the iteration.

  • Algorithm stops if lambda_tol is reached or when newton_iteration failed to converge or diverge.

  • Algorithm needs an estimate of the upperbound for lambda to work.

Parameters
problem_functionfunc(lambda) -> StaticProblem

Function with argument the optimization parameter lambda returning a valid StaticProblem object.

initial_guess=Nonevalid initial_guess input for StaticProblem.compute()

Initial guess for problem_function(0) used as starting point for iteration. At subsequent iterations the solution theta of highest valid lambda so far is used. None means problem_function(0).approximate() is used. Alternative input: initial_guess(lambda) -> theta. Initial guess used at every iteration.

lambda_tol=DEF_MAX_PAR_TOLfloat

Target precision for parameter lambda. Stops iterating if upperbound - lowerbound < lambda_tol * lower_bound.

estimated_upper_bound=1.0float

Estimate for the upperbound for lambda.

maxiter=DEF_MAX_PAR_MAXITERint

Maximum number of iterations.

stepsize_reduction_factor=DEF_MAX_PAR_REDUCE_FACTfloat

Lambda is multiplied by this factor every time an upper_bound is found.

require_stability=Truebool

If True, convergence to a state that is dynamically unstable is considered diverged. (see StaticConfiguration.is_stable())

require_vortex_configuration_equals_target=Truebool

If True, A result of .compute() is only considered a solution if its vortex configuration matches its set “target” vortex configuration in the source static_problem.

compute_parameters: dict or func(lambda) -> dict

Keyword-argument parameters passed to problem_function(lambda).compute() defined as a dictionary or as a function with lambda as input that generates a dictionary.

Returns
lambda_lowerboundfloat

Lowerbound of lambda.

lambda_upperboundfloat

Upperbound of lambda.

configStaticConfiguration

Containing solutions at lambda=lambda_lowerbound

iteration_infoParameterOptimizeInfo

Object containing information about the iteration.

class static_problem.CurrentPhaseRelation(func, d_func, i_func)[source]

Current-Phase relation Icp(Ic, theta). The default value is Icp = Ic * sin(theta).

Parameters
funcfunc(Ic, theta)

Current-phase relation.

d_funcfunc(Ic, theta)

Derivative of current-phase relation to theta.

i_funcfunc(Ic, theta)

Integral of current-phase relation over theta (starting at 0).

Notes

  • func, d_func and i_func must be numpy ufunc, so their output must be broadcast of input Ic and theta.

Methods

d_eval(Ic, theta)

Evaluate derivative of current phase relation; returns d_func(Ic, theta).

eval(Ic, theta)

Evaluate current phase relation; returns func(Ic, theta).

i_eval(Ic, theta)

Evaluate integral of current phase relation; returns i_func(Ic, theta).

d_eval(Ic, theta)[source]

Evaluate derivative of current phase relation; returns d_func(Ic, theta).

eval(Ic, theta)[source]

Evaluate current phase relation; returns func(Ic, theta).

i_eval(Ic, theta)[source]

Evaluate integral of current phase relation; returns i_func(Ic, theta).

class static_problem.DefaultCPR[source]

Default current-phase relation Icp = Ic * sin(theta).

Methods

d_eval(Ic, theta)

Evaluate derivative of current phase relation; returns d_func(Ic, theta).

eval(Ic, theta)

Evaluate current phase relation; returns func(Ic, theta).

i_eval(Ic, theta)

Evaluate integral of current phase relation; returns i_func(Ic, theta).

static_problem.node_to_junction_current(circuit: pyjjasim.josephson_circuit.Circuit, node_current)[source]

Conversion from node_current to junction_current.

Parameters
node_current(Nn,) array

At each node how much current is injected or ejected (+ if injected)

Returns
junction_current: (Nj,) array

Returns a configuration of currents at each junction such that at any node the net injected current through all its neighbouring edges matches the specified node_current.

class static_problem.NewtonIterInfo(tol, maxiter)[source]

Information about the newton iteration used to find static configurations. Use print(newton_iter_info) to display the information.

Methods

found_target_solution()

Returns True if has_converged() and final iter obeys target vortex config.

get_is_target_vortex_configuration()

Returns (nr_of_iters,) bool array if vortex configuration at iter agrees with vortex configuration specified in problem.

get_max_iter()

Returns number of iterations after which iteration is aborted.

get_number_of_iterations()

Returns number of newton iterations done.

get_residual()

Returns (nr_of_iters,) array containing residual at each iteration.

get_runtime()

Returns runtime in seconds.

get_status()

Returns status of newton iteration result; returns value:

get_tol()

Returns tolerance.

has_converged()

Returns if iteration has converged.

plot_residuals()

Plots residual vs iteration number.

found_target_solution()[source]

Returns True if has_converged() and final iter obeys target vortex config.

get_is_target_vortex_configuration()[source]

Returns (nr_of_iters,) bool array if vortex configuration at iter agrees with vortex configuration specified in problem.

get_max_iter()[source]

Returns number of iterations after which iteration is aborted.

get_number_of_iterations()[source]

Returns number of newton iterations done.

get_residual()[source]

Returns (nr_of_iters,) array containing residual at each iteration.

get_runtime()[source]

Returns runtime in seconds.

get_status()[source]
Returns status of newton iteration result; returns value:
  • 0: converged. residual < tolerance

  • 1: diverged before reaching maxiter.

  • 2: reached max_iter without converging or diverging.

get_tol()[source]

Returns tolerance.

has_converged()[source]

Returns if iteration has converged.

plot_residuals()[source]

Plots residual vs iteration number.

class static_problem.ParameterOptimizeInfo(problem_func, lambda_tol, require_stability, require_target_n, maxiter)[source]

Information about the parameter optimization process. Use print(parameter_optimize_info) to display a summary of the information.

Methods

get_found_solution()

Returns (nr_of_steps,) array if a stable target solution is found at step.

get_has_solution_at_zero()

Returns if a stable target solution is found at lambda=0.

get_is_stable()

Returns (nr_of_steps,) array if a stable target solution is found at step.

get_is_target_vortex_configuration()

Returns (nr_of_steps,) array if a solution has target vortex configuration.

get_lambda()

Returns (nr_of_steps,) array with lambda at each step.

get_lambda_error()

Returns (nr_of_steps,) array with error in lambda.

get_lambda_lower_bound()

Returns lower bound for lambda.

get_lambda_upper_bound()

Returns upper bound for lambda.

get_newton_iter_all_info()

Returns (nr_of_steps,) list containing newton_iter_infos.

get_newton_steps()

Returns (nr_of_steps,) array with nr of newton iterations at step.

get_runtime()

Returns runtime in seconds.

plot_residuals()

Plots residual vs iteration number.

animate_solutions

get_found_solution()[source]

Returns (nr_of_steps,) array if a stable target solution is found at step.

get_has_solution_at_zero()[source]

Returns if a stable target solution is found at lambda=0.

get_is_stable()[source]

Returns (nr_of_steps,) array if a stable target solution is found at step.

get_is_target_vortex_configuration()[source]

Returns (nr_of_steps,) array if a solution has target vortex configuration.

get_lambda()[source]

Returns (nr_of_steps,) array with lambda at each step.

get_lambda_error()[source]

Returns (nr_of_steps,) array with error in lambda.

get_lambda_lower_bound()[source]

Returns lower bound for lambda.

get_lambda_upper_bound()[source]

Returns upper bound for lambda.

get_newton_iter_all_info()[source]

Returns (nr_of_steps,) list containing newton_iter_infos.

get_newton_steps()[source]

Returns (nr_of_steps,) array with nr of newton iterations at step.

get_runtime()[source]

Returns runtime in seconds.

plot_residuals()[source]

Plots residual vs iteration number.