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(fileprefix)

Write to a file the particle density matrix of the wave function.

  • file_name : string

    Name of the file.

write_phase(fileprefix)

Write to a file the phase of the wave function.

  • file_name : string

    Name of the file.

write_to_file(fileprefix)

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(_grid, _n_x=1, _n_y=1, _norm=1, _phase=0, _p_real=None, _p_imag=None)
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(fileprefix)

Write to a file the particle density matrix of the wave function.

  • file_name : string

    Name of the file.

write_phase(fileprefix)

Write to a file the phase of the wave function.

  • file_name : string

    Name of the file.

write_to_file(fileprefix)

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(grid, omega_x, omega_y=-1.0, mean_x=0, mean_y=0, norm=1, phase=0, p_real=None, p_imag=None)
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(fileprefix)

Write to a file the particle density matrix of the wave function.

  • file_name : string

    Name of the file.

write_phase(fileprefix)

Write to a file the phase of the wave function.

  • file_name : string

    Name of the file.

write_to_file(fileprefix)

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(_grid, _n_x=1, _n_y=1, _norm=1, _phase=0, _p_real=None, _p_imag=None)
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(fileprefix)

Write to a file the particle density matrix of the wave function.

  • file_name : string

    Name of the file.

write_phase(fileprefix)

Write to a file the phase of the wave function.

  • file_name : string

    Name of the file.

write_to_file(fileprefix)

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(x, y)

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
class trottersuzuki.HarmonicPotential(_grid, _omegax, _omegay, _mass=1.0, _mean_x=0.0, _mean_y=0.0)
get_value(x, y)

Return the value of the external potential at coordinate (x,y)

Hamiltonian Classes

class trottersuzuki.Hamiltonian(_grid, _potential=None, _mass=1.0, _coupling_a=0.0, _angular_velocity=0.0, _rot_coord_x=0, _rot_coord_y=0)
class trottersuzuki.Hamiltonian2Component(_grid, _potential=None, _potential_b=None, _mass=1.0, _mass_b=1.0, _coupling_a=0.0, coupling_ab=0.0, _coupling_b=0.0, _omega_r=0, _omega_i=0, _angular_velocity=0.0, _rot_coord_x=0, _rot_coord_y=0)

Solver Class

class trottersuzuki.Solver(*args)
evolve(iterations, imag_time=False)

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