Setting Options for the Dynamics SolversΒΆ
Occasionally it is necessary to change the built in parameters of the dynamics solvers used by for example the qutip.mesolve
and qutip.mcsolve
functions. The options for all dynamics solvers may be changed by using the Options class qutip.solver.Options
.
In [1]: options = Options()
the properties and default values of this class can be view via the print function:
In [2]: print(options)
Options:
-----------
atol: 1e-08
rtol: 1e-06
method: adams
order: 12
nsteps: 1000
first_step: 0
min_step: 0
max_step: 0
tidy: True
num_cpus: 2
norm_tol: 0.001
norm_steps: 5
rhs_filename: None
rhs_reuse: False
seeds: 0
rhs_with_state: False
average_expect: True
average_states: False
ntraj: 500
store_states: False
store_final_state: False
These properties are detailed in the following table. Assuming options = Options()
:
As an example, let us consider changing the number of processors used, turn the GUI off, and strengthen the absolute tolerance. There are two equivalent ways to do this using the Options class. First way,
In [3]: options = Options()
In [4]: options.num_cpus = 3
In [5]: options.atol = 1e-10
or one can use an inline method,
In [6]: options = Options(num_cpus=4, atol=1e-10)
Note that the order in which you input the options does not matter. Using either method, the resulting options variable is now:
In [7]: print(options)
Options:
-----------
atol: 1e-10
rtol: 1e-06
method: adams
order: 12
nsteps: 1000
first_step: 0
min_step: 0
max_step: 0
tidy: True
num_cpus: 4
norm_tol: 0.001
norm_steps: 5
rhs_filename: None
rhs_reuse: False
seeds: 0
rhs_with_state: False
average_expect: True
average_states: False
ntraj: 500
store_states: False
store_final_state: False
To use these new settings we can use the keyword argument options
in either the func:qutip.mesolve and qutip.mcsolve
function. We can modify the last example as:
>>> mesolve(H0, psi0, tlist, c_op_list, [sigmaz()], options=options)
>>> mesolve(hamiltonian_t, psi0, tlist, c_op_list, [sigmaz()], H_args, options=options)
or:
>>> mcsolve(H0, psi0, tlist, ntraj,c_op_list, [sigmaz()], options=options)
>>> mcsolve(hamiltonian_t, psi0, tlist, ntraj, c_op_list, [sigmaz()], H_args, options=options)