Grid1d#

class scqubits.core.discretization.Grid1d(min_val, max_val, pt_count)[source]#

Data structure and methods for setting up discretized 1d coordinate grid, generating corresponding derivative matrices.

Parameters:
  • min_val (float) – minimum value of the discretized variable

  • max_val (float) – maximum value of the discretized variable

  • pt_count (int) – number of grid points

Return type:

SerializableType

Methods

Grid1d.__init__(min_val, max_val, pt_count)

Grid1d.broadcast(event, **kwargs)

Request a broadcast from CENTRAL_DISPATCH reporting event.

Grid1d.create_from_file(filename)

Read initdata and spectral data from file, and use those to create a new SpectrumData object.

Grid1d.deserialize(io_data)

Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.

Grid1d.filewrite(filename)

Convenience method bound to the class.

Grid1d.first_derivative_matrix([prefactor, ...])

Generate sparse matrix for first derivative of the form \(\partial_{x_i}\).

Grid1d.get_initdata()

Returns dict appropriate for creating/initializing a new Grid1d object.

Grid1d.grid_spacing()

rtype:

float

Grid1d.make_linspace()

Returns a numpy array of the grid points :rtype: ndarray

Grid1d.receive(event, sender, **kwargs)

Receive a message from CENTRAL_DISPATCH and initiate action on it.

Grid1d.second_derivative_matrix([prefactor, ...])

Generate sparse matrix for second derivative of the form \(\partial^2_{x_i}\).

Grid1d.serialize()

Convert the content of the current class instance into IOData format.

Attributes

max_val

Descriptor class for properties that are to be monitored for changes.

min_val

Descriptor class for properties that are to be monitored for changes.

pt_count

Descriptor class for properties that are to be monitored for changes.

broadcast(event, **kwargs)#

Request a broadcast from CENTRAL_DISPATCH reporting event.

Parameters:
  • event (str) – event name from EVENTS

  • **kwargs

Return type:

None

classmethod create_from_file(filename)#

Read initdata and spectral data from file, and use those to create a new SpectrumData object.

Returns:

new SpectrumData object, initialized with data read from file

Return type:

SpectrumData

Parameters:

filename (str) –

classmethod deserialize(io_data)#

Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.

Return type:

TypeVar(SerializableType, bound= Serializable)

Parameters:

io_data (IOData) –

filewrite(filename)#

Convenience method bound to the class. Simply accesses the write function.

Return type:

None

Parameters:

filename (str) –

first_derivative_matrix(prefactor=1.0, periodic=False)[source]#

Generate sparse matrix for first derivative of the form \(\partial_{x_i}\). Uses STENCIL setting to construct the matrix with a multi-point stencil.

Parameters:
  • prefactor (Union[float, complex]) – prefactor of the derivative matrix (default value: 1.0)

  • periodic (bool) – set to True if variable is a periodic variable

Return type:

csc_matrix

Returns:

sparse matrix in dia format

get_initdata()[source]#

Returns dict appropriate for creating/initializing a new Grid1d object. :rtype: dict

Return type:

Dict[str, Any]

grid_spacing()[source]#
Return type:

float

Returns:

spacing between neighboring grid points

make_linspace()[source]#

Returns a numpy array of the grid points :rtype: ndarray

Return type:

ndarray

receive(event, sender, **kwargs)#

Receive a message from CENTRAL_DISPATCH and initiate action on it.

Parameters:
  • event (str) – event name from EVENTS

  • sender (DispatchClient) – original sender reporting the event

  • **kwargs

Return type:

None

second_derivative_matrix(prefactor=1.0, periodic=False)[source]#

Generate sparse matrix for second derivative of the form \(\partial^2_{x_i}\). Uses STENCIL setting to construct the matrix with a multi-point stencil.

Parameters:
  • prefactor (Union[float, complex]) – optional prefactor of the derivative matrix (default value = 1.0)

  • periodic (bool) – set to True if variable is a periodic variable (default value = False)

Return type:

csc_matrix

Returns:

sparse matrix in dia format

serialize()#

Convert the content of the current class instance into IOData format.

Return type:

IOData