package ppmrmn;

public class Nmr extends Jacobi {

  private double spin = (n - 1)/2.0; //Attention
  private double omegaQ;
  private double omegaRF;

  public Nmr(double omeQ, double omeRF) {
    omegaQ = omeQ*(2*Math.PI);  // kHz
    omegaRF = omeRF*(2*Math.PI);  // kHz
  }

  public RealMat dataIn(){
    RealMat matH = new RealMat(); //matH est la matrice Hamiltonien

    for (int i = 0; i < n; i++)
      matH.re[i][i] = omegaQ*(3*(spin - i)*(spin - i) - spin*(spin + 1))/3;
    for (int i = 0; i < n - 1; i++) {
      matH.re[i][i+1] = -omegaRF*Math.sqrt(spin*(spin + 1)
                        - (spin - i)*(spin - i - 1))/2;
      matH.re[i+1][i] = matH.re[i][i+1];
    }
    return matH;
  } // End of datain

  public RealMat matriceQuadrupole(){
    RealMat matH = new RealMat(); //matH est la matrice Hamiltonien Quadruplaire 1er ordre
    for (int i = 0; i < n; i++)
      matH.re[i][i] = omegaQ*(3*(spin - i)*(spin - i) - spin*(spin + 1))/3;
    return matH;
  }

  public RealMat matriceIz() {
    RealMat matIz = new RealMat();
    for (int i = 0; i < n; i++)
      matIz.re[i][i] = spin - i;
    return matIz;
  }

  public ComplexMat matriceHamilton(RealMat matH, double t) {
    double c = 0;
    ComplexMat matHH = new ComplexMat();
    for (int i = 0; i < n; i++) {
      c = matH.re[i][i]*t;
      matHH.re[i][i] = Math.cos(c);
      matHH.im[i][i] = Math.sin(c);
    }
    return matHH;
  }

  public double getOmegaQ(){
    return omegaQ;
  }

  public void setOmegaQ(double x){
    this.omegaQ = x;
  }

  public double getOmegaRF(){
    return omegaRF;
  }

  public double getSpin(){
    return spin;
  }

} //End of class Nmr