Function Reference¶
Lattice Class¶
-
class
trottersuzuki.
Lattice
(dim=100, length=20.0, periodic_x_axis=False, periodic_y_axis=False, angular_velocity=0.0)¶
State Classes¶
-
class
trottersuzuki.
State
(*args)¶ -
get_mean_px
()¶ Return the expected value of the \(P_x\) operator.
- mean_px : float
Expected value of the \(P_x\) operator.
-
get_mean_pxpx
()¶ Return the expected value of the \(P_x^2\) operator.
- mean_pxpx : float
Expected value of the \(P_x^2\) operator.
-
get_mean_py
()¶ Return the expected value of the \(P_y\) operator.
- mean_py : float
Expected value of the \(P_y\) operator.
-
get_mean_pypy
()¶ Return the expected value of the \(P_y^2\) operator.
- mean_pypy : float
Expected value of the \(P_y^2\) operator.
-
get_mean_x
()¶ Return the expected value of the \(X\) operator.
- mean_x : float
Expected value of the \(X\) operator.
-
get_mean_xx
()¶ Return the expected value of the \(X^2\) operator.
- mean_xx : float
Expected value of the \(X^2\) operator.
-
get_mean_y
()¶ Return the expected value of the \(Y\) operator.
- mean_y : float
Expected value of the \(Y\) operator.
-
get_mean_yy
()¶ Return the expected value of the \(Y^2\) operator.
- mean_yy : float
Expected value of the \(Y^2\) operator.
-
get_particle_density
()¶ Return a matrix storing the squared norm of the wave function.
- particle_density : numpy matrix
Particle density of the state \(|\psi(x,y)|^2\)
-
get_phase
()¶ Return a matrix of the wave function’s phase.
- get_phase : numpy matrix
Matrix of the wave function’s phase \(\phi(x,y) = \log(\psi(x,y))\)
-
get_squared_norm
()¶ Return the squared norm of the quantum state.
- squared_norm : float
Squared norm of the quantum state.
-
imprint
(function)¶ Multiply the wave function of the state by the function provided.
- function : python function
Function to be printed on the state.
Useful, for instance, to imprint solitons and vortices on a condensate. Generally, it performs a transformation of the state whose wave function becomes
\[\psi(x,y)' = f(x,y) \psi(x,y)\]being \(f(x,y)\) the input function and \(\psi(x,y)\) the initial wave function.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> def vortex(x,y): # Vortex function >>> z = x + 1j*y >>> angle = np.angle(z) >>> return np.exp(1j * angle) >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.imprint(vortex) # Imprint a vortex on the state
-
init_state
(state_function)¶ Initialize the wave function of the state using a function.
- state_function : python function
Python function defining the wave function of the state \(\psi\).
The input arguments of the python function must be (x,y).
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> def wave_function(x,y): # Define a flat wave function >>> return 1. >>> state = ts.State(grid) # Create the system's state >>> state.ini_state(wave_function) # Initialize the wave function of the state
-
write_particle_density
(*args)¶ Write to a file the particle density matrix of the wave function.
- file_name : string
Name of the file.
-
write_phase
(*args)¶ Write to a file the phase of the wave function.
- file_name : string
Name of the file.
-
write_to_file
(*args)¶ Write to a file the wave function.
- file_name : string
Name of the file to be written.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.write_to_file('wave_function.txt') # Write to a file the wave function >>> state2 = ts.State(grid) # Create a quantum state >>> state2.loadtxt('wave_function.txt') # Load the wave function
-
-
class
trottersuzuki.
ExponentialState
(*args)¶ -
get_mean_px
()¶ Return the expected value of the \(P_x\) operator.
- mean_px : float
Expected value of the \(P_x\) operator.
-
get_mean_pxpx
()¶ Return the expected value of the \(P_x^2\) operator.
- mean_pxpx : float
Expected value of the \(P_x^2\) operator.
-
get_mean_py
()¶ Return the expected value of the \(P_y\) operator.
- mean_py : float
Expected value of the \(P_y\) operator.
-
get_mean_pypy
()¶ Return the expected value of the \(P_y^2\) operator.
- mean_pypy : float
Expected value of the \(P_y^2\) operator.
-
get_mean_x
()¶ Return the expected value of the \(X\) operator.
- mean_x : float
Expected value of the \(X\) operator.
-
get_mean_xx
()¶ Return the expected value of the \(X^2\) operator.
- mean_xx : float
Expected value of the \(X^2\) operator.
-
get_mean_y
()¶ Return the expected value of the \(Y\) operator.
- mean_y : float
Expected value of the \(Y\) operator.
-
get_mean_yy
()¶ Return the expected value of the \(Y^2\) operator.
- mean_yy : float
Expected value of the \(Y^2\) operator.
-
get_particle_density
()¶ Return a matrix storing the squared norm of the wave function.
- particle_density : numpy matrix
Particle density of the state \(|\psi(x,y)|^2\)
-
get_phase
()¶ Return a matrix of the wave function’s phase.
- get_phase : numpy matrix
Matrix of the wave function’s phase \(\phi(x,y) = \log(\psi(x,y))\)
-
get_squared_norm
()¶ Return the squared norm of the quantum state.
- squared_norm : float
Squared norm of the quantum state.
-
imprint
(function)¶ Multiply the wave function of the state by the function provided.
- function : python function
Function to be printed on the state.
Useful, for instance, to imprint solitons and vortices on a condensate. Generally, it performs a transformation of the state whose wave function becomes
\[\psi(x,y)' = f(x,y) \psi(x,y)\]being \(f(x,y)\) the input function and \(\psi(x,y)\) the initial wave function.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> def vortex(x,y): # Vortex function >>> z = x + 1j*y >>> angle = np.angle(z) >>> return np.exp(1j * angle) >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.imprint(vortex) # Imprint a vortex on the state
-
write_particle_density
(*args)¶ Write to a file the particle density matrix of the wave function.
- file_name : string
Name of the file.
-
write_phase
(*args)¶ Write to a file the phase of the wave function.
- file_name : string
Name of the file.
-
write_to_file
(*args)¶ Write to a file the wave function.
- file_name : string
Name of the file to be written.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.write_to_file('wave_function.txt') # Write to a file the wave function >>> state2 = ts.State(grid) # Create a quantum state >>> state2.loadtxt('wave_function.txt') # Load the wave function
-
-
class
trottersuzuki.
GaussianState
(*args)¶ -
get_mean_px
()¶ Return the expected value of the \(P_x\) operator.
- mean_px : float
Expected value of the \(P_x\) operator.
-
get_mean_pxpx
()¶ Return the expected value of the \(P_x^2\) operator.
- mean_pxpx : float
Expected value of the \(P_x^2\) operator.
-
get_mean_py
()¶ Return the expected value of the \(P_y\) operator.
- mean_py : float
Expected value of the \(P_y\) operator.
-
get_mean_pypy
()¶ Return the expected value of the \(P_y^2\) operator.
- mean_pypy : float
Expected value of the \(P_y^2\) operator.
-
get_mean_x
()¶ Return the expected value of the \(X\) operator.
- mean_x : float
Expected value of the \(X\) operator.
-
get_mean_xx
()¶ Return the expected value of the \(X^2\) operator.
- mean_xx : float
Expected value of the \(X^2\) operator.
-
get_mean_y
()¶ Return the expected value of the \(Y\) operator.
- mean_y : float
Expected value of the \(Y\) operator.
-
get_mean_yy
()¶ Return the expected value of the \(Y^2\) operator.
- mean_yy : float
Expected value of the \(Y^2\) operator.
-
get_particle_density
()¶ Return a matrix storing the squared norm of the wave function.
- particle_density : numpy matrix
Particle density of the state \(|\psi(x,y)|^2\)
-
get_phase
()¶ Return a matrix of the wave function’s phase.
- get_phase : numpy matrix
Matrix of the wave function’s phase \(\phi(x,y) = \log(\psi(x,y))\)
-
get_squared_norm
()¶ Return the squared norm of the quantum state.
- squared_norm : float
Squared norm of the quantum state.
-
imprint
(function)¶ Multiply the wave function of the state by the function provided.
- function : python function
Function to be printed on the state.
Useful, for instance, to imprint solitons and vortices on a condensate. Generally, it performs a transformation of the state whose wave function becomes
\[\psi(x,y)' = f(x,y) \psi(x,y)\]being \(f(x,y)\) the input function and \(\psi(x,y)\) the initial wave function.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> def vortex(x,y): # Vortex function >>> z = x + 1j*y >>> angle = np.angle(z) >>> return np.exp(1j * angle) >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.imprint(vortex) # Imprint a vortex on the state
-
write_particle_density
(*args)¶ Write to a file the particle density matrix of the wave function.
- file_name : string
Name of the file.
-
write_phase
(*args)¶ Write to a file the phase of the wave function.
- file_name : string
Name of the file.
-
write_to_file
(*args)¶ Write to a file the wave function.
- file_name : string
Name of the file to be written.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.write_to_file('wave_function.txt') # Write to a file the wave function >>> state2 = ts.State(grid) # Create a quantum state >>> state2.loadtxt('wave_function.txt') # Load the wave function
-
-
class
trottersuzuki.
SinusoidState
(*args)¶ -
get_mean_px
()¶ Return the expected value of the \(P_x\) operator.
- mean_px : float
Expected value of the \(P_x\) operator.
-
get_mean_pxpx
()¶ Return the expected value of the \(P_x^2\) operator.
- mean_pxpx : float
Expected value of the \(P_x^2\) operator.
-
get_mean_py
()¶ Return the expected value of the \(P_y\) operator.
- mean_py : float
Expected value of the \(P_y\) operator.
-
get_mean_pypy
()¶ Return the expected value of the \(P_y^2\) operator.
- mean_pypy : float
Expected value of the \(P_y^2\) operator.
-
get_mean_x
()¶ Return the expected value of the \(X\) operator.
- mean_x : float
Expected value of the \(X\) operator.
-
get_mean_xx
()¶ Return the expected value of the \(X^2\) operator.
- mean_xx : float
Expected value of the \(X^2\) operator.
-
get_mean_y
()¶ Return the expected value of the \(Y\) operator.
- mean_y : float
Expected value of the \(Y\) operator.
-
get_mean_yy
()¶ Return the expected value of the \(Y^2\) operator.
- mean_yy : float
Expected value of the \(Y^2\) operator.
-
get_particle_density
()¶ Return a matrix storing the squared norm of the wave function.
- particle_density : numpy matrix
Particle density of the state \(|\psi(x,y)|^2\)
-
get_phase
()¶ Return a matrix of the wave function’s phase.
- get_phase : numpy matrix
Matrix of the wave function’s phase \(\phi(x,y) = \log(\psi(x,y))\)
-
get_squared_norm
()¶ Return the squared norm of the quantum state.
- squared_norm : float
Squared norm of the quantum state.
-
imprint
(function)¶ Multiply the wave function of the state by the function provided.
- function : python function
Function to be printed on the state.
Useful, for instance, to imprint solitons and vortices on a condensate. Generally, it performs a transformation of the state whose wave function becomes
\[\psi(x,y)' = f(x,y) \psi(x,y)\]being \(f(x,y)\) the input function and \(\psi(x,y)\) the initial wave function.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> def vortex(x,y): # Vortex function >>> z = x + 1j*y >>> angle = np.angle(z) >>> return np.exp(1j * angle) >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.imprint(vortex) # Imprint a vortex on the state
-
write_particle_density
(*args)¶ Write to a file the particle density matrix of the wave function.
- file_name : string
Name of the file.
-
write_phase
(*args)¶ Write to a file the phase of the wave function.
- file_name : string
Name of the file.
-
write_to_file
(*args)¶ Write to a file the wave function.
- file_name : string
Name of the file to be written.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> state.write_to_file('wave_function.txt') # Write to a file the wave function >>> state2 = ts.State(grid) # Create a quantum state >>> state2.loadtxt('wave_function.txt') # Load the wave function
-
Potential Classes¶
-
class
trottersuzuki.
Potential
(*args)¶ -
get_value
(*args)¶ Get the value at the lattice’s coordinate (x,y).
- value : float
Value of the external potential.
-
init_potential
(pot_function)¶ Initialize the external potential.
- potential_function : python function
Define the external potential function.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> # Define a constant external potential >>> def external_potential_function(x,y): >>> return 1. >>> potential = ts.Potential(grid) # Create the external potential >>> potential.init_potential(external_potential_function) # Initialize the external potential
-
Hamiltonian Classes¶
-
class
trottersuzuki.
Hamiltonian
(*args)¶
-
class
trottersuzuki.
Hamiltonian2Component
(*args)¶
Solver Class¶
-
class
trottersuzuki.
Solver
(*args)¶ -
evolve
(*args)¶ Evolve the state of the system.
- iterations : integer
Number of iterations.
- imag_time : bool,optional (default: False)
Whether to perform imaginary time evolution (True) or real time evolution (False).
The norm of the state is preserved both in real-time and in imaginary-time evolution.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> potential = ts.HarmonicPotential(grid, 1., 1.) # Create harmonic potential >>> hamiltonian = ts.Hamiltonian(grid, potential) # Create a harmonic oscillator Hamiltonian >>> solver = ts.Solver(grid, state, hamiltonian, 1e-2) # Create the solver >>> solver.evolve(1000) # perform 1000 iteration in real time evolution
-
get_inter_species_energy
()¶ Get the inter-particles interaction energy of the system.
- get_inter_species_energy : float
Inter-particles interaction energy of the system.
-
get_intra_species_energy
(which=3)¶ Get the intra-particles interaction energy of the system.
- which : integer,optional (default: 3)
Which intra-particles interaction energy to return: total system (default, which=3), first component (which=1), second component (which=2).
- get_intra_species_energy : float
Intra-particles interaction energy of the system.
-
get_kinetic_energy
(which=3)¶ Get the kinetic energy of the system.
- which : integer,optional (default: 3)
Which kinetic energy to return: total system (default, which=3), first component (which=1), second component (which=2).
- get_kinetic_energy : float
kinetic energy of the system.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> potential = ts.HarmonicPotential(grid, 1., 1.) # Create harmonic potential >>> hamiltonian = ts.Hamiltonian(grid, potential) # Create a harmonic oscillator Hamiltonian >>> solver = ts.Solver(grid, state, hamiltonian, 1e-2) # Create the solver >>> solver.get_kinetic_energy() # Get the kinetic energy 0.5
-
get_potential_energy
(which=3)¶ Get the potential energy of the system.
- which : integer,optional (default: 3)
Which potential energy to return: total system (default, which=3), first component (which=1), second component (which=2).
- get_potential_energy : float
Potential energy of the system.
-
get_rabi_energy
()¶ Get the Rabi energy of the system.
- get_rabi_energy : float
Rabi energy of the system.
-
get_rotational_energy
(which=3)¶ Get the rotational energy of the system.
- which : integer,optional (default: 3)
Which rotational energy to return: total system (default, which=3), first component (which=1), second component (which=2).
- get_rotational_energy : float
Rotational energy of the system.
-
get_squared_norm
(which=3)¶ Get the squared norm of the state (default: total wave-function).
- which : integer,optional (default: 3)
Which squared state norm to return: total system (default, which=3), first component (which=1), second component (which=2).
- get_squared_norm : float
Squared norm of the state.
-
get_total_energy
()¶ Get the total energy of the system.
- get_total_energy : float
Total energy of the system.
>>> import trottersuzuki as ts # import the module >>> grid = ts.Lattice() # Define the simulation's geometry >>> state = ts.GaussianState(grid, 1.) # Create the system's state >>> potential = ts.HarmonicPotential(grid, 1., 1.) # Create harmonic potential >>> hamiltonian = ts.Hamiltonian(grid, potential) # Create a harmonic oscillator Hamiltonian >>> solver = ts.Solver(grid, state, hamiltonian, 1e-2) # Create the solver >>> solver.get_total_energy() # Get the total energy 1
-