Polarization.h 1.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
15
// Polarization.h
16 17 18
//
////////////////////////////////////////////////////////////////////////////////

19 20
#ifndef POLARIZATION_H
#define POLARIZATION_H
21 22 23 24 25 26 27

#include<iostream>
#include<iomanip>
#include<sstream>

#include "Sample.h"

28
class Polarization: public Var
29 30 31 32 33
{
  Sample *s;

  public:

34
  const char *name ( void ) const { return "polarization"; };
35 36 37 38 39 40

  int set ( int argc, char **argv )
  {
    if ( argc != 2 )
    {
      if ( ui->onpe0() )
41
      cout << " polarization takes only one value" << endl;
42 43 44 45 46
      return 1;
    }

    string v = argv[1];

47 48 49
    if ( v == "OFF" || v == "MLWF" || v == "MLWF_REF" || v == "MLWF_REF_Q" ||
         v == "BERRY" )
      s->ctrl.polarization = v;
50 51 52
    else
    {
      if ( ui->onpe0() )
53 54
      cout <<
      " polarization must be OFF, MLWF, MLWF_REF, MLWF_REF_Q or BERRY" << endl;
55 56 57 58 59 60 61 62 63 64 65
      return 1;
    }
    return 0;
  }

  string print (void) const
  {
     ostringstream st;
     st.setf(ios::left,ios::adjustfield);
     st << setw(10) << name() << " = ";
     st.setf(ios::right,ios::adjustfield);
66
     st << s->ctrl.polarization;
67 68 69
     return st.str();
  }

70
  Polarization(Sample *sample) : s(sample)
71
  {
72
    s->ctrl.polarization = "OFF";
73 74 75
  }
};
#endif