InteractionsContainer getInteractions()
{
  InteractionFactory interactions;
  InteractionsContainer result;

  Vector3 xhat(1.0, 0.0, 0.0);
  result.insert(interactions.getExchange("J", -1.0, "sl0", "sl1", 0.4, 0.6));
  result.insert(interactions.getAnisotropy("D", 0.1, xhat, "sl1"));
  result.insert(interactions.getAnisotropy("D", 0.1, xhat, "sl0"));

  return result;
}
Ejemplo n.º 2
0
int main()
{
    Cell cell;
    cell.setBasisVectors(1.0,10.0,10.0,90.0,90.0,90.0);
    
    Sublattice spin0;
    string name0 = "Spin0";
    spin0.setName(name0);
    spin0.setType("NONE");
    spin0.setMoment(1.0,0.0,0.0);
    cell.addSublattice(spin0);
    cell.addAtom(name0,0.0,0.0,0.0);
    
    Sublattice spin1;
    string name1 = "Spin1";
    spin1.setName(name1);
    spin1.setType("NONE");
    spin1.setMoment(1.0,M_PI,0.0);
    cell.addSublattice(spin1);
    cell.addAtom(name1,0.5,0.0,0.0);
    
    SpinWaveBuilder builder(cell);
    
    InteractionFactory interactions;
    
    Vector3 xhat(1.0,0.0,0.0);
    builder.addInteraction(interactions.getExchange("J",-1.0,name0,name1,0.4,0.6));
    builder.addInteraction(interactions.getAnisotropy("D",0.1,xhat,name0));
    builder.addInteraction(interactions.getAnisotropy("D",0.1,xhat,name1));
    SpinWave SW = builder.createElement();
    
    PointsAlongLine Line;
    Line.setFirstPoint(0.0,0.0,0.0);
    Line.setFinalPoint(0.0,0.0,3.0*2.0*M_PI);
    Line.setNumberPoints(201);
    ThreeVectors<double> kPoints = Line.getPoints();
    
    Energies energies(0.2, 3.0, 201);
    
    OneDimensionalFactory factory;
    auto gauss = factory.getGaussian(0.15,1.0e-1);
    
    unique_ptr<SpinWavePlot> res(new EnergyResolutionFunction(move(gauss), SW,energies));
    unique_ptr<SpinWavePlot> cut(new IntegrateThetaPhi(move(res),1.0e-1));

    TwoDimensionalCut twodimcut;
    twodimcut.setFilename("AFMPowderAverage");
    twodimcut.setPlotObject(move(cut));
    twodimcut.setPoints(kPoints);
    twodimcut.save();
    return 0;
}
Ejemplo n.º 3
0
int main()
{
    
    double gamma,eta,J,B;
    
    gamma = -2.0;
    eta = -2.0;
    J = 1.0;
    B = 8.0;
    
    double theta = M_PI_2;
    theta = acos(-B/(4.0*gamma));
    cout << "Theta = " << theta << endl;
    
    Cell cell;
    cell.setBasisVectors(1.0,2.0,10.0,90.0,90.0,90.0);
    
    Sublattice a1;
    string name1 = "a1";
    a1.setName(name1);
    a1.setType("NONE");
    a1.setMoment(1.0,theta,0.0);
    cell.addSublattice(a1);
    cell.addAtom(name1,0.0,0.0,0.0);
    
    Sublattice b1;
    string name2 = "b1";
    b1.setName(name2);
    b1.setType("NONE");
    b1.setMoment(1.0,theta,M_PI);
    cell.addSublattice(b1);
    cell.addAtom(name2,0.0,0.5,0.0);

    SpinWaveBuilder builder(cell);
    
    InteractionFactory interactions;
    
    builder.addInteraction(interactions.getExchange("J",J,name1,name1,0.9,1.1));
    builder.addInteraction(interactions.getExchange("metaJ",-1.0*eta*J,name2,name2,0.9,1.1));
    builder.addInteraction(interactions.getExchange("gammaJ",gamma*J,name1,name2,0.9,1.1));
    
    Vector3 zhat(0.0,0.0,1.0);
    builder.addInteraction(interactions.getMagneticField("B",B,zhat,name1));
    builder.addInteraction(interactions.getMagneticField("B",B,zhat,name2));

    SpinWave test = builder.createElement();
    
    PointsAlongLine Line;
    Line.setFirstPoint(0.0,1.0,0.0);
    Line.setFinalPoint(0.0,2.0,0.0);
    Line.setNumberPoints(11);
    ThreeVectors<double> kPoints = Line.getPoints();
    
    SpinWaveDispersion dispersion;
    dispersion.setFilename("AFMChain.txt");
    dispersion.setGenie(test);
    dispersion.setPoints(kPoints);
    
    dispersion.save();
    
    /*double kx(0.0),ky(0.0);
    double R2Kp = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0+cos(ky));
    double R2Km = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0-cos(ky));
    double term = (eta+1.0)*(cos(kx)-1.0);
    cout << sqrt(R2Kp*R2Km) +term << " " << sqrt(R2Kp*R2Km) +term << endl;
    cout << sqrt(R2Kp/R2Km) << " " << sqrt(R2Kp/R2Km) << endl;
    
    kx = M_PI;
    R2Kp = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0+cos(ky));
    R2Km = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0-cos(ky));
    term = (eta+1.0)*(cos(kx)-1.0);
    cout << sqrt(R2Kp*R2Km) +term << " " << sqrt(R2Kp*R2Km) -term << endl;
    cout << sqrt(R2Kp/R2Km) << " " << sqrt(R2Kp/R2Km) << endl;

    kx = 2.0*M_PI;
    R2Kp = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0+cos(ky));
    R2Km = (eta-1.0)*(cos(kx)-1.0)+2.0*gamma*(-1.0-cos(ky));
    term = (eta+1.0)*(cos(kx)-1.0);
    cout << sqrt(R2Kp*R2Km) +term << " " << sqrt(R2Kp*R2Km) +term << endl;
    cout << sqrt(R2Kp/R2Km) << " " << sqrt(R2Kp/R2Km) << endl;
*/
    return 0;
}
Ejemplo n.º 4
0
void Init::parseInteractionNode(const pugi::xml_node &node)
{
     SpinWaveBuilder buildertemp(unit_cell);
     builder = buildertemp;
     InteractionFactory factory;
    
     pugi::xml_node exchange = node.child("Exchange");
     for (pugi::xml_node tool = exchange.child("group"); tool; tool = tool.next_sibling("group"))
     {
         cout << "Exchange: " << endl;
         
         string name = tool.child_value("name");
         algorithm::trim(name); // get rid of surrounding whitespace

         double value,min,max;
         
         value = stringToDouble(tool.child_value("value"));
         min = stringToDouble(tool.child_value("mindist"));
         max = stringToDouble(tool.child_value("maxdist"));
         
         pugi::xml_node pairs = tool.child("pairs");
         for (pugi::xml_node pair = pairs.child("pair"); pair; pair = pair.next_sibling("pair"))
         {
             string atom1 = pair.child_value("name1");
             string atom2 = pair.child_value("name2");
             
             cout << name << " " << value <<" " << atom1 << " " <<  atom2 << " " << min << " " << " " << max << endl;
             builder.addInteraction(factory.getExchange(name,value,atom1,atom2,min,max));

         }
     }
    
    pugi::xml_node DzyaloshinskyMoriya = node.child("DzyaloshinskyMoriya");
    for (pugi::xml_node tool = DzyaloshinskyMoriya.child("group"); tool; tool = tool.next_sibling("group"))
    {
        cout << "Dzyaloshinsky-Moriya: " << endl;
        
        string name = tool.child_value("name");
        algorithm::trim(name); // get rid of surrounding whitespace
        
        double value,min,max;
        value = stringToDouble(tool.child_value("value"));
        min = stringToDouble(tool.child_value("min"));
        max = stringToDouble(tool.child_value("max"));
        
        double x,y,z;
        
        x = stringToDouble(tool.child("direction").child_value("x"));
        y = stringToDouble(tool.child("direction").child_value("y"));
        z = stringToDouble(tool.child("direction").child_value("z"));
        
        cout << x << '\t' << y << '\t' << z << endl;
        
        Vector3 direction(x,y,z);
        
        pugi::xml_node pairs = tool.child("pairs");
        for (pugi::xml_node pair = pairs.child("pair"); pair; pair = pair.next_sibling("pair"))
        {
            string atom1 = pair.child_value("name1");
            string atom2 = pair.child_value("name2");
            
            cout << name << " " << value <<" " << atom1 << " " <<  atom2 << " " << min << " " << " " << max << endl;
            builder.addInteraction( factory.getDzyaloshinskiiMoriya(name,value,direction,atom1,atom2,min,max) );
        }
    }
    
    pugi::xml_node anisotropy = node.child("Anisotropy");
    
    for (pugi::xml_node tool = anisotropy.child("group"); tool; tool = tool.next_sibling("group"))
    {
        cout << "Anisotropy: " << endl;
        
        string identifier = tool.child_value("name");
        algorithm::trim(identifier); // get rid of surrounding whitespace
        
        double value,x,y,z;
        
        value = stringToDouble(tool.child_value("value"));
        x = stringToDouble(tool.child("direction").child_value("x"));
        y = stringToDouble(tool.child("direction").child_value("y"));
        z = stringToDouble(tool.child("direction").child_value("z"));
    
        cout << x << '\t' << y << '\t' << z << endl;
            
        pugi::xml_node sublattices = tool.child("sublattices");
        for (pugi::xml_node name = sublattices.child("name"); name; name = name.next_sibling("name"))
        {
            string atom1 = name.child_value();
            Vector3 direction(x,y,z);
            cout << "direction= " << direction.transpose() << endl;
            builder.addInteraction(factory.getAnisotropy(identifier,value,direction,atom1));
        }
    }
}
Ejemplo n.º 5
0
int main()
{
    std::array<double,4> BValues{{0.0,4.0,8.0,10.0}};
    for (auto B:BValues)
    {
      double gamma,eta,J;
      gamma = -2.0;
      eta = -2.0;
      J = 1.0;
    
      double theta = M_PI_2;
      theta = acos(-B/(4.0*gamma));
      if (theta != theta) //check for nan
        theta = 0.0;
      cout << "Theta = " << theta << endl;
    
      Cell cell;
      cell.setBasisVectors(1.0,2.0,10.0,90.0,90.0,90.0);
    
      Sublattice a1;
      string name1 = "a1";
      a1.setName(name1);
      a1.setType("NONE");
      a1.setMoment(1.0,theta,0.0);
      cell.addSublattice(a1);
      cell.addAtom(name1,0.0,0.0,0.0);
    
      Sublattice b1;
      string name2 = "b1";
      b1.setName(name2);
      b1.setType("NONE");
      b1.setMoment(1.0,theta,M_PI);
      cell.addSublattice(b1);
      cell.addAtom(name2,0.0,0.5,0.0);

      SpinWaveBuilder builder(cell);
    
      InteractionFactory interactions;
    
      builder.addInteraction(interactions.getExchange("J",J,name1,name1,0.9,1.1));
      builder.addInteraction(interactions.getExchange("metaJ",-1.0*eta*J,name2,name2,0.9,1.1));
      builder.addInteraction(interactions.getExchange("gammaJ",gamma*J,name1,name2,0.9,1.1));
    
      Vector3 zhat(0.0,0.0,1.0);
      builder.addInteraction(interactions.getMagneticField("B",B,zhat,name1));
      builder.addInteraction(interactions.getMagneticField("B",B,zhat,name2));

      SpinWave test = builder.createElement();
    
      PointsAlongLine Line;
      Line.setFirstPoint(0.5,0.0,0.0);
      Line.setFinalPoint(0.0,0.0,0.0);
      Line.setNumberPoints(101);
      ThreeVectors<double> kPoints = Line.getPoints();
    
      Line.setFirstPoint(0.0,0.0,0.0);
      Line.setFinalPoint(0.0,1.0,0.0);
      Line.setNumberPoints(101);
      ThreeVectors<double> kPoints2 = Line.getPoints();
    
      SpinWaveDispersion dispersion;
      dispersion.setFilename("SC2Chain_"+std::to_string(static_cast<int>(B))+".txt");
      dispersion.setGenie(test);
      dispersion.setPoints(kPoints);
      dispersion.setPoints(kPoints2);
      dispersion.save();
    
    }
    return 0;
}
Ejemplo n.º 6
0
SpinWaveGenie::SpinWave createModel()
{
    // Cell object stores the basis vectors and Sublattice objects
    Cell cell;
    // set a,b,c,alpha,beta,gamma in units of Angstroms, Degrees
    cell.setBasisVectors(5.4,5.4,7.63675323681,90.0,90.0,90.0);
    
    // parameters used for calculating angles
    double delta = 0.00516;
    double phi = 0.0032;
    
    Sublattice Fe1;
    //each Sublattice contains:
    //  a unique name,
    std::string name1 = "Fe1";
    Fe1.setName(name1);
    //  type (used to calculate the magnetic form factor)
    Fe1.setType("FE3");
    //  magnetic moment (magnitude,theta (radians), phi (radians))
    Fe1.setMoment(2.5,M_PI/2.0-delta,M_PI+phi);
    //add sublattice to Cell cell.
    cell.addSublattice(Fe1);
    // add atom to sublattice name1 at position (0,0.5,0) in reduced lattice units.
    cell.addAtom(name1,0.0,0.5,0.0);

    //repeat for Sublattice Fe2,Fe3 and Fe4
    Sublattice Fe2;
    std::string name2 = "Fe2";
    Fe2.setName(name2);
    Fe2.setType("FE3");
    Fe2.setMoment(2.5,M_PI/2.0-delta,phi);
    cell.addSublattice(Fe2);
    cell.addAtom(name2,0.0,0.5,0.5);

    Sublattice Fe3;
    std::string name3 = "Fe3";
    Fe3.setName(name3);
    Fe3.setType("FE3");
    Fe3.setMoment(2.5,M_PI/2.0-delta,M_PI-phi);
    cell.addSublattice(Fe3);
    cell.addAtom(name3,0.5,0.0,0.5);

    Sublattice Fe4;
    std::string name4 = "Fe4";
    Fe4.setName(name4);
    Fe4.setType("FE3");
    Fe4.setMoment(2.5,M_PI/2.0-delta,2.0*M_PI-phi);
    cell.addSublattice(Fe4);
    cell.addAtom(name4,0.5,0.0,0.0);
    
    // add Cell cell to the builder
    SpinWaveBuilder builder(cell);
    
    // Factory for defining interactions.
    InteractionFactory interactions;
   
    Vector3 xhat(1.0,0.0,0.0);
    // get anisotropy interaction named "Ka" with value "-0.0055" in the "xhat" direction on sublattice name1.
    // pass this interaction to the builder.
    // repeat for interactions name2,name3,name4
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name1));
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name2));
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name3));
    builder.addInteraction(interactions.getAnisotropy("Ka",-0.0055,xhat,name4));

    Vector3 zhat(0.0,0.0,1.0);
    // get anisotropy interaction named "Kc" with value "-0.00305" in the "zhat" direction on sublattice name1.
    // pass this interaction to the builder.
    // repeat for interactions name2,name3,name4
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name1));
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name2));
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name3));
    builder.addInteraction(interactions.getAnisotropy("Kc",-0.00305,zhat,name4));

    // get exchange interaction named "J1" with value "-4.77" between sublattices name1 and name2.
    // limit atoms to those between 3.8 and 4.3 angstroms.
    // pass this interaction to the builder.
    // repeat for interactions between name1 and name4, name2 and name3, name3 and name4.
    builder.addInteraction(interactions.getExchange("J1",-4.77,name1,name2,3.8,4.3));
    builder.addInteraction(interactions.getExchange("J1",-4.77,name1,name4,3.8,4.3));
    builder.addInteraction(interactions.getExchange("J1",-4.77,name3,name2,3.8,4.3));
    builder.addInteraction(interactions.getExchange("J1",-4.77,name3,name4,3.8,4.3));
    
    // get exchange interaction named "J2" with value "-0.21" between sublattices name1 and name1.
    // limit atoms to those between 5.3 and 5.5 angstroms.
    // pass this interaction to the builder.
    // repeat for interactions between other pairs.
    builder.addInteraction(interactions.getExchange("J2",-0.21,name1,name1,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name2,name2,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name3,name3,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name4,name4,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name1,name3,5.3,5.5));
    builder.addInteraction(interactions.getExchange("J2",-0.21,name2,name4,5.3,5.5));

    Vector3 yhat(0.0,1.0,0.0);
    // get Dzyaloshinskii-Moriya interaction named "D1" with value "-0.074" in the yhat direction between sublattices name4 and name1.
    // limit atoms to those between 3.8 and 4.3 angstroms.
    // pass this interaction to the builder.
    // repeat for interactions between other pairs.
    builder.addInteraction(interactions.getDzyaloshinskiiMoriya("D1",-0.074,yhat,name4,name1,3.8,4.3));
    builder.addInteraction(interactions.getDzyaloshinskiiMoriya("D1",-0.074,yhat,name2,name3,3.8,4.3));

    // get Dzyaloshinskii-Moriya interaction named "D2" with value "-0.028" in the zhat direction between sublattices name4 and name1.
    // limit atoms to those between 3.8 and 4.3 angstroms.
    // pass this interaction to the builder.
    // repeat for interactions between other pairs.
    builder.addInteraction(interactions.getDzyaloshinskiiMoriya("D2",-0.028,zhat,name4,name1,3.8,4.3));
    builder.addInteraction(interactions.getDzyaloshinskiiMoriya("D2",-0.028,zhat,name3,name2,3.8,4.3));

    //return SpinWave object containing the cell, sublattices and interactions.
    return builder.createElement();
}