Exemplo 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();
}
Exemplo 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;
}
Exemplo 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;
}
Exemplo n.º 4
0
void Init::parseTwoDimensionCut(const pugi::xml_node &node)
{
    
    cout << "Two Dimension Cut:" << endl;
    string filename = node.child_value("filename");
    string filetype = node.child_value("filetype");
    
    TwoDimensionCut Cut;
    Cut.setFilename(filename);
    
    cout << filename << endl;
    
    {
        pugi::xml_node group = node.child("setkpoints");
        double x0,y0,z0,x1,y1,z1,NumberPoints;
        string temp;
        
        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);
        Cut.setPoints(Line.getPoints());
        

    }
        
    {
        pugi::xml_node group = node.child("setenergypoints");
        double MinEnergy,MaxEnergy,NumberPoints;
        string temp;
        
        NumberPoints = stringToDouble(group.child_value("numberpoints"));
        MinEnergy = stringToDouble(group.child_value("firstpoint"));
        MaxEnergy = stringToDouble(group.child_value("lastpoint"));
        
        cout << MinEnergy << " " << MaxEnergy << " " << NumberPoints << endl;
        
        PointsAlongLine Line;

        pugi::xml_node type = node.child("type");
        
        pugi::xml_node Gaussian = type.child("OneDimensionGaussian");
        pugi::xml_node Lorentzian = type.child("OneDimensionLorentzian");
        pugi::xml_node PseudoVoigt = type.child("OneDimensionPseudoVoigt");
        
        OneDimensionalFactory factory;
        
        unique_ptr<OneDimensionalShapes> resinfo;
        
        if (Gaussian)
        {
            double fwhm,tolerance;
            fwhm = stringToDouble(Gaussian.child_value("fwhm"));
            tolerance = stringToDouble(Gaussian.child_value("tol"));
            
            resinfo = factory.getGaussian(fwhm,tolerance);
            cout << "Gaussian resolution function set" << endl;
        }
        else if(Lorentzian)
        {
            double fwhm,tolerance;
            fwhm = stringToDouble(Lorentzian.child_value("fwhm"));
            tolerance = stringToDouble(Lorentzian.child_value("tol"));

            resinfo = factory.getLorentzian(fwhm,tolerance);
            
            cout << "Lorentzian resolution function set" << endl;
        }
        else if(PseudoVoigt)
        {
            double eta,fwhm,tolerance;
            eta = stringToDouble(PseudoVoigt.child_value("eta"));
            fwhm = stringToDouble(PseudoVoigt.child_value("fwhm"));
            tolerance = stringToDouble(PseudoVoigt.child_value("tol"));
            
            resinfo = factory.getPseudoVoigt(eta,fwhm,tolerance);
            
            cout << "Pseudo-Voigt resolution function set" << endl;
        }
        else
        {
            cout << "RESOLUTION FUNCTION NOT SET!!!" << endl;
        }
        
        SpinWave SW = builder.createElement();
        unique_ptr<SpinWavePlot> res(new EnergyResolutionFunction(move(resinfo), SW, Energies(MinEnergy, MaxEnergy, NumberPoints)));
        Cut.setPlotObject(move(res));
        Cut.setEnergyPoints(MinEnergy,MaxEnergy,NumberPoints);
    }
    Cut.save();


}
Exemplo 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;
}