⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 state.h

📁 使用量子轨道方法计算量子主方程的C++库
💻 H
📖 第 1 页 / 共 2 页
字号:
    // save and recover results of a calculation.  friend istream& operator>>( istream&, State& );    // inputs a state in a standard ASCII form.  This can be used to    // save and recover results of a calculation.// Information-returning and utility member functions  void xerox(const State& a);    // make MINIMAL copy of State (for use in temps).  Improves efficiency    // when dynamical allocation of basis states is being used.  Chiefly    // used by the Operator class; should not be needed by ordinary users.    // For an explanation of the dynamical allocation see adjustCutoff    // below.  int size();			// length of data array  int getSize(int = 0);		// size of nth degree of freedom  void diagnostic();		// debugging info  void normalize();		// normalize state, i.e., psi*psi = 1// Member functions accessing coordinates; for a full explanation of// this, see the basis-changing member functions below.  Complex centerCoords();    // return center of coordinates  Complex getCoords(int = 0);    // center of coordinates of nth freedom (default 0)  void setCoords(Complex&,int=0);    // set the value of the coords for a freedom (default 0)  void displaceCoords(Complex&, int=0);    // adds a Complex displacement to the center of    // coordinates of a freedom (default freedom is 0)  double checkBounds(int, int=2);    // check amplitudes of top basis states    // (default: top 2 basis states)// Basis-changing member functions// This QSD library makes use of the localization property to greatly// improve the efficiency of calculations.  In QSD, for a wide variety// of problems, field states tend towards highly localized wavepackets// in phase space.  These wave packets are closely centered on some point// alpha (a Complex number) which is given by the expectation value// alpha = <a>, where a is the harmonic oscillator annihilation operator.//// If alpha is large, it requires a great many ordinary Fock states to// represent such a wavepacket; the number of Fock states n goes like// |alpha|^2.  By choosing a different set of basis states an enormous// savings is possible.//// We use the excited coherent state basis |alpha,n> to represent our// states, choosing alpha=<a> for maximum efficiency.  (Ordinary Fock// states would correspond to alpha=0.)  As the value of <a> will change// with time, the basis must also be changed fairly often.  This adds to// the cost of a calculation; but the savings from the moving basis// far outweigh this added complexity.//// Note that this only applies to freedoms of type FIELD.  For multiple// degree-of-freedom states, each FIELD degree of freedom can be moved// separately.  Trying to move the basis of a non-FIELD freedom will// produce an error.//// Note also that the user is not required to use the moving basis.  For// problems without strong localization, the moving basis adds to the// computational overhead while producing little benefit, and should not// be invoked.//// For further details, see J. Phys. A 28, 5401-5413 (1995).  void moveCoords(const Complex& displacement, int theFreedom=0,      double shiftAccuracy=1e-4);    // Relative shift of the center of coordinates.  displacement    // gives the amount by which to shift alpha, theFreedom indicates    // which degree of freedom is to be shifted.  shiftAccuracy    // gives the accuracy with which to make the shift    // (default 1e-4).  The physical state is unchanged, but it is    // represented in a new basis |alpha+displacement,n>    // Uses private moveStep member function.  void recenter(int theFreedom=0,double shiftAccuracy=1e-4);    // Recenters freedom theFreedom at its expectation value in phase space.    // The physical state is unchanged, but is represented in a new    // basis |<a>,n>, a being the annihilation operator for the    // selected degree of freedom.  Uses moveCoords.  void moveToCoords(const Complex& alpha, int theFreedom=0,      double shiftAccuracy=1e-4);    // Like moveCoords, but instead of shifting by a Complex displacement    // it moves the basis to a new absolute position alpha in phase space.    // Uses moveCoords.  void centerOn(State& psi,double shiftAccuracy=1e-4);    // Leaves the physical state unchanged, but represents it in the    // same basis as the given state psi.  Uses moveCoords.  Can be used    // with multiple degree-of-freedom states, though the states must    // have the same number and type of freedoms; it will change the    // basis only of the FIELD degrees of freedom.// Cutoff-adjusting member functions// For efficiency, it is possible to restrict the number of basis vectors// actually used by including only those with amplitudes appreciably// greater than zero.  The criterion used is based on two parameters:// epsilon and padSize.  All of the top states of a freedom whose total// probability is less than epsilon are excluded except for a number of// "buffer" basis states, or "pad", equal to padSize.  If the "pad" begins// to gain appreciable probability (i.e., probability over epsilon) the// number of basis states can be dynamically increased.  In this way,// no more basis states are used than are necessary.  This is particularly// useful in conjunction with the moving basis.  void adjustCutoff(int theFreedom=0, double epsilon=1e-4, int padSize=2);    // adjust amount of storage used by the State by adjusting the    // cutoff for freedom number theFreedom.  void fullSize();	// makes size of state match physical size of storageprivate:			// private data and functionss// SkipVector part -- used to act on single degree of freedom in memory//// The QSD code assumes that all Operators are defined in terms of Primary// Operators which act on a single degree of freedom.  In order for this// to work successfully, it must be possible to loop over a single degree// of freedom, leaving all the others unchanged.  This is embodied in the// notion of a SkipVector -- a data structure which is treated like an// ordinary array, but steps through memory by an ``skip'' larger than one.  Complex* myPointer;		// pointer to storage  int mySize;			// array size  int nSkip;			// steps between elements (the ``skip'')// One dimensional state part --// used for greater efficiency in 1 Freedom problems  int totalDim;			// total number of elements  int maxSize;			// number of elements actually used  FreedomType myType;		// type of freedom  Complex* data;		// element storage; this points to an array				// of complex numbers giving the amplitudes				// of the basis states  Complex coord;		// center of coordinates in phase space				// (see the moving basis, above)// MultiState part -- used for >1 degrees of freedom//// The basis states for a multiple-degree-of-freedom state are the// products of the basis states of the individual degrees of freedom// which make up the total state.  If there are n_i basis states to// represent the ith degree of freedom, then a particular basis state// of the total state is given by indices {i_0,...,i_N} for an N+1 freedom// state.//// The amplitudes for these basis states are stored in the array data,// just as for single degree-of-freedom states.  The amplitude for the// basis state {i_0,...,i_N} is stored at the location////   loc = i_0 + i_1*n_0 + i_2*n_0*n_1 + ... + i_N*n_0*...*n_(N-1).//// where i_m ranges from 0 to n_m-1.//// Incrementing the mth index by 1 is equivalent to stepping through// the data array by an amount////   nSkips[m] = n_0*n_1*...*n_(m-1).  int nFreedoms;		// number of degrees of freedom  int* nDims;			// number of dimensions (basis states)				// for each freedom  int* sizes;			// number of dimensions (basis states)				// actually used by each freedom  int* nSkips;			// index spacing in data field of ith freedom  int* partDims;		// subspace dim of first i freedoms  FreedomType* freedomTypes;	// types of degrees of freedom (FIELD, SPIN, etc.)  Complex* coords;		// centers of coordinates in phase space// Private member functions  void apply(PrimaryOperator&, int, int, FreedomType, double);    // apply a PrimaryOperator to a State  void copy(const State&);		// copy a state  void free();				// recycle storage  void moveStep(Complex&, Complex&);	// shift coords by infinitesimal step  void stretchFreedom(int,int);		// increase storage used by a freedom  void shrinkFreedom(int,int);		// compact storage used by a freedom  void error(const char*) const;	// print out error message and exit  friend class Operator;			// friend class};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -