TimeAxis

Class representing time in time dependent calculations.

User level function of the Quantarhei package. To be used as:

>>> import quantarhei as qr
>>> time = qr.TimeAxis()

The TimeAxis class stands in a close relation to FrequencyAxis class of the quantarhei package. FrequencyAxis represents the frequencies one obtains in the Fast Fourier transform of a function of the TimeAxis. By default, TimeAxis is of the type upper-half which means that by specifying the start, length and step we represent the upper half of the interval <start-length*step, start+(length-1)*step>. The Fourier transform of a time dependent object defined on the TimeAxis will then have twice as many points as the TimeAxis. This is usefull when the time dependent object has some special symmetries. One example is the so-called quantum bath correlation function which fulfills the relation (in LaTeX)

C(-t) = C^{*}(t)

Examples

Default TimeAxis is of the ‘upper-half’ type

>>> ta = TimeAxis(0.0,100,0.1)
>>> ta.atype
'upper-half'

It is defined between the start and start+(length-1)*step

>>> '%.3f' % ta.min
'0.000'
>>> '%.3f' % ta.max
'9.900'

However, when we ask for the corresponding FrequencyAxis, we get an array of frequencies which is twice as long and contains 2*length points

>>> wa = ta.get_FrequencyAxis()
>>> print(wa.length)
200

The frequency step is therefore twice shorter than one would normally expect.

>>> print(wa.step == wa.step)
True
>>> import numpy
>>> print(numpy.allclose(wa.step,2.0*numpy.pi/(0.1*200)))
True

This definition of the TimeAxis is used in conjunction with the symmetries of the corelation functions, lineshape functions and response functions.

In some case you want the ‘complete’ type of the TimeAxis.

>>> ta = TimeAxis(0.0,100,1.0,atype="complete")
>>> ta.atype
'complete'

In this case the relation of the TimeAxis and the FrequencyAxis is more straightforward. Now, the TimeAxis represents the interval on which a time dependent object is defined completely. The number of points in the corresponding FrequencyAxis is the same as in the TimeAxis and the frequency step is as expected from a normal FFT.

>>> wa = ta.get_FrequencyAxis()
>>> print(wa.length)
100
>>> print(wa.step == wa.step)
True
>>> import numpy
>>> print(numpy.allclose(wa.step,2.0*numpy.pi/(1.0*100)))
True

No other types than complete and upper-half are defined at the moment. The following with throw an Exception

>>> ta = TimeAxis(0.0,100,1.0,atype="lower-half")
Traceback (most recent call last):
...
Exception: Unknown time axis type

Relation between TimeAxis and FrequencyAxis

Complete TimeAxis and even number of points

>>> ta = TimeAxis(0.0,10,0.1,atype="complete")
>>> times = [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
>>> print(numpy.allclose(ta.data,times))
True
>>> wa = ta.get_FrequencyAxis()
>>> freques = 2.0*numpy.pi*numpy.fft.fftshift(numpy.fft.fftfreq(10,0.1))
>>> print(numpy.allclose(wa.data,freques))
True
>>> print(numpy.allclose(wa.step,freques[1]-freques[0]))
True
>>> tb = wa.get_TimeAxis()
>>> print(numpy.allclose(tb.data,times))
True
>>> wb = tb.get_FrequencyAxis()
>>> print(numpy.allclose(wb.data,freques))
True

Complete TimeAxis and odd number of points

>>> ta = TimeAxis(0.0,11,0.1,atype="complete")
>>> times = [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
>>> print(numpy.allclose(ta.data,times))
True
>>> wa = ta.get_FrequencyAxis()
>>> freques = 2.0*numpy.pi*numpy.fft.fftshift(numpy.fft.fftfreq(11,0.1))
>>> print(numpy.allclose(wa.data,freques))
True
>>> print(numpy.allclose(wa.step,freques[1]-freques[0]))
True
>>> tb = wa.get_TimeAxis()
>>> print(numpy.allclose(tb.data,times))
True
>>> wb = tb.get_FrequencyAxis()
>>> print(numpy.allclose(wb.data,freques))
True

Upper-half TimeAxis and even number of points

>>> ta = TimeAxis(0.0,10,0.1)
>>> print(ta.atype=="upper-half")
True
>>> times = [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]
>>> print(numpy.allclose(ta.data,times))
True
>>> wa = ta.get_FrequencyAxis()
>>> freques = 2.0*numpy.pi*numpy.fft.fftshift(numpy.fft.fftfreq(20,0.1))
>>> print(numpy.allclose(wa.data,freques))
True
>>> print(numpy.allclose(wa.step,freques[1]-freques[0]))
True
>>> tb = wa.get_TimeAxis()
>>> print(numpy.allclose(tb.data,times))
True
>>> wb = tb.get_FrequencyAxis()
>>> print(numpy.allclose(wb.data,freques))
True

Upper-half TimeAxis and odd number of points

>>> ta = TimeAxis(0.0,11,0.1)
>>> times = [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
>>> print(numpy.allclose(ta.data,times))
True
>>> wa = ta.get_FrequencyAxis()
>>> freques = 2.0*numpy.pi*numpy.fft.fftshift(numpy.fft.fftfreq(2*11,0.1))
>>> print(numpy.allclose(wa.data,freques))
True
>>> print(numpy.allclose(wa.step,freques[1]-freques[0]))
True
>>> tb = wa.get_TimeAxis()
>>> print(numpy.allclose(tb.data,times))
True
>>> wb = tb.get_FrequencyAxis()
>>> print(numpy.allclose(wb.data,freques))
True

Class Details

class quantarhei.core.time.TimeAxis(start=0.0, length=1, step=1.0, atype='upper-half', frequency_start=0.0)[source]

Class representing time in time dependent calculations.

Parameters:
  • start (float) – start of the TimeAxis
  • length (int) – number of steps
  • step (float) – time step
  • atype (string {"complete","upper-half"}) – Axis type
Attributes:
length
max

Returns the maximum value on the axis

min

Returns the minimum value on the axis

start
step

Methods

copy() Returns a shallow copy of the self
deepcopy() Returns a deep copy of the self
get_FrequencyAxis() Returns corresponding FrequencyAxis object
is_equal_to(axis) Returns True if the axis is equal to this ValueAxis
is_extension_of(axis) Returns True if the axis is contained in this ValueAxis
is_subsection_of(axis) Returns True if the axis contains this ValueAxis
is_subset_of(axis) Returns True if the ValueAxis is a subset of axis
is_superset_of(axis) Returns True if the ValueAxis is a superset of axis
load(filename[, test]) Loads an object from a file and returns it
loaddir(dirname) Returns a directory of objects saved into a directory
locate(val) Returns the index of the lower neigbor of the val
nearest(val) Returns the index of the nearest neighbor to val
save(filename[, comment, test]) Saves the object with all its content into a file
savedir(dirname[, tag, comment, test]) Saves an object into directory containing a file with unique name
scopy() Creates a copy of the object by saving and loading it
shift_to_zero() Shifts the values so that the first one is zero
get_FrequencyAxis()[source]

Returns corresponding FrequencyAxis object

shift_to_zero()[source]

Shifts the values so that the first one is zero