コード例 #1
0
ファイル: SQuIDS.cpp プロジェクト: jsalvado/SQuIDS
void SQuIDS::ini(unsigned int n, unsigned int nsu, unsigned int nrh, unsigned int nsc, double ti){
  /*
    Setting the number of energy bins, number of components for the density matrix and
    number of scalar functions
  */

  nx=n;
  nsun=nsu;
  nrhos=nrh;
  nscalars=nsc;
  size_rho=nsun*nsun;
  size_state=(size_rho*nrhos+nscalars);
  /*
    Setting time units and initial time
  */
  t_ini=ti;
  t=ti;

  //Allocate memory for the system
  unsigned int numeqn=nx*size_state;
  system.reset(new double[numeqn]);
  sys.dimension = static_cast<size_t>(numeqn);

  /*
    Initializing the SU algebra object, needed to compute algebraic operations like commutators,
    anticommutators, rotations and evolutions
  */

  //Allocate memory
  x.resize(nx);

  state.reset(new SU_state[nx]);
  estate.reset(new SU_state[nx]);
  dstate.reset(new SU_state[nx]);

  for(unsigned int ei = 0; ei < nx; ei++){
    state[ei].rho.reset(new SU_vector[nrhos]);
    estate[ei].rho.reset(new SU_vector[nrhos]);
    dstate[ei].rho.reset(new SU_vector[nrhos]);
  }

  //initially, estate just points to the same memory as state
  for(unsigned int ei = 0; ei < nx; ei++){
    for(unsigned int i=0;i<nrhos;i++){
      state[ei].rho[i]=SU_vector(nsun,&(system[ei*size_state+i*size_rho]));
      estate[ei].rho[i]=SU_vector(nsun,&(system[ei*size_state+i*size_rho]));
      dstate[ei].rho[i]=SU_vector(nsun,nullptr);
    }
    if(nscalars>0){
      state[ei].scalar=&(system[ei*size_state+nrhos*size_rho]);
      estate[ei].scalar=&(system[ei*size_state+nrhos*size_rho]);
    }
  }
  last_dstate_ptr=nullptr;
  last_estate_ptr=nullptr;

  is_init=true;
};
コード例 #2
0
ファイル: rabi.cpp プロジェクト: nega0/SQuIDS
void rabi::init(double D_E, double wi, double Am){
  Delta_E=D_E;
  w=wi;
  A=Am;
  params.SetMixingAngle(0,1,params.pi/4);
  ini(1,2,1,0,0);

  Set_CoherentInteractions(true);  

  evol_b0_proj.reset(new SU_vector[nx*nsun]);
  evol_b1_proj.reset(new SU_vector[nx*nsun]);
  b0_proj.reset(new SU_vector[nsun]);
  b1_proj.reset(new SU_vector[nsun]);

  for(int i = 0; i < nsun; i++){
    b0_proj[i]=SU_vector::Projector(nsun,i);
    b1_proj[i]=SU_vector::Projector(nsun,i);
    b1_proj[i].RotateToB1(params);

    for(int ei = 0; ei < nx; ei++){
      evol_b0_proj[i*nx + ei]=SU_vector::Projector(nsun,i);
      evol_b1_proj[i*nx + ei]=SU_vector::Projector(nsun,i);
      evol_b1_proj[i*nx + ei].RotateToB1(params);
    }
  }

  suH0=SU_vector(nsun);
  d=SU_vector(nsun);
  d0=SU_vector(nsun);

  d0=(b1_proj[0]-b1_proj[1]);
  suH0 = b0_proj[1]*Delta_E;

  // set initial conditions for the density matrix.
  state[0].rho[0] = b0_proj[0];
}