Esempio n. 1
0
void Init::parseDispersion(const pugi::xml_node &node)
{
    
    cout << "Dispersion:" << endl;
    string filename = node.child_value("filename");
    string filetype = node.child_value("filetype");
    
    SpinWaveDispersion Dispersion;
    Dispersion.setFilename(filename);
    
    SpinWaveDispersion::Options PrintOptions;
    string temp;
    bool value;
    
    temp = node.child("filetype").child_value("printposition");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintPosition;
    cout << "print position: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    temp = node.child("filetype").child_value("printfrequency");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintFrequency;
    cout << "print frequency: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    temp = node.child("filetype").child_value("printintensity");
    value = boost::lexical_cast<bool, std::string>(temp);
    PrintOptions = SpinWaveDispersion::Options::PrintIntensity;
    cout << "print intensity: "<< value << endl;
    Dispersion.setOptions(PrintOptions,value);
    
    pugi::xml_node lines = node.child("lines");
    for (pugi::xml_node group = lines.child("group");group; group = group.next_sibling("group"))
    {
        double x0,y0,z0,x1,y1,z1,NumberPoints;
        
        NumberPoints = stringToDouble(group.child_value("numberpoints"));
        x0 = stringToDouble(group.child("firstpoint").child_value("x"));
        y0 = stringToDouble(group.child("firstpoint").child_value("y"));
        z0 = stringToDouble(group.child("firstpoint").child_value("z"));
        x1 = stringToDouble(group.child("lastpoint").child_value("x"));
        y1 = stringToDouble(group.child("lastpoint").child_value("y"));
        z1 = stringToDouble(group.child("lastpoint").child_value("z"));
        
        cout << x0 << " " << y0 << " " << z0 << " " << x1 << " " << y1 << "  " << z1 << endl;
        
        PointsAlongLine Line;
        Line.setFirstPoint(x0,y0,z0);
        Line.setFinalPoint(x1,y1,z1);
        Line.setNumberPoints(NumberPoints);
        Dispersion.setPoints(Line.getPoints());
    }
    
    Dispersion.setGenie(builder.createElement());
    Dispersion.save();
}
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;
}
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;
}