MSpin-JCoupling  2.1
jequation.h
1 /***************************************************************************
2  jequation.h - description
3  -------------------
4  author : Armando Navarro-Vazquez
5  email : armando.deus@gmail.com
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #if !defined JEQUATION_H
18 #define JEQUATION_H
19 
20 #include <string>
21 #include <vector>
22 #include <sstream>
23 
24 #include <magnes/molecule.h>
25 #include <magnes/couplingconstant.h>
26 #ifdef WIN32
27 #include <windows.h>
28 #define JEQUATION_EXPORT __declspec(dllexport)
29 #ifdef JEQUATIONDLL
30 #define JEQUATION_API __declspec(dllexport)
31 #else
32 #define JEQUATION_API __declspec(dllimport)
33 #endif
34 #else
35 #define JEQUATION_API
36 #define JEQUATION_EXPORT
37 #endif
38 
39 
45 namespace magnes
46 {
47  class JEquationPrivate;
53  class JEQUATION_API JEquation
54  {
55  public:
56 
62  class JEQUATION_API Parameter
63  {
64  public:
69  Parameter(const std::string& name, float value) {_name=name; _value=value; }
72  void SetName(const std::string& name) { _name=name; }
76  const std::string& Name() const { return _name; }
78  void SetValue(float value) { _value=value; }
80  float Value() const { return _value; }
81  private:
82  std::string _name;
83  float _value;
84  };
85 
91  class JEQUATION_API ParameterSet
92  {
93  public:
97  ParameterSet(const std::string& name) { _name=name; }
99  const std::vector<Parameter>& Set() const { return _set; }
101  std::vector<Parameter>& Set() { return _set; }
103  std::string Name() const { return _name; }
105  void SetName(const std::string& name) { _name=name; }
109  ParameterSet& operator << (Parameter f) { _set.push_back(f); return *this;}
111  void Save(std::ostream& s) const;
112  private:
113  std::vector<Parameter> _set;
114  std::string _name;
115  };
116 
118  JEquation();
120  virtual ~JEquation();
121 
123  virtual float GetJ(const Frame& frame, size_t i, size_t j) =0;
125  void CoupledPairs(Molecule* molecule, std::vector<magnes::CouplingConstant>& pairs);
127  virtual std::string Name() const =0;
129  virtual std::pair < std::string , std::string > CoupledNuclei() const =0;
131  virtual int NBonds() const =0;
135  virtual std::string Description() const;
140  std::string Group() const;
142  void SetGroup(const std::string& group);
144  virtual bool SelectFirstAtom(const Molecule* molecule, size_t i) =0;
146  virtual bool SelectSecondAtom(const Molecule* molecule, size_t i) =0;
147 
149  void SetParameters(std::vector<Parameter>& newparams,int i);
151  const ParameterSet& GetParameterSet(size_t i) const;
153  ParameterSet& GetParameterSet(size_t i);
155  const ParameterSet& GetCurrentParameterSet() const;
157  ParameterSet& GetCurrentParameterSet();
159  const std::vector<ParameterSet>& GetParameterSets() const;
161  std::vector<ParameterSet>& GetParameterSets();
163  size_t GetCurrentParameterSetIndex() const;
165  void SetCurrentSet(size_t n);
167  virtual void InitParameters() =0;
169  void SaveParameters(std::ostream& s) const;
171  void LoadParameters(std::istream& s);
172  private:
173  void ExtractParameters(std::istream& s, ParameterSet& p);
174  std::string GetParametersOrEquationName(const std::string& line);
175  protected:
176 
178  size_t m_s1;
180  size_t m_s2;
181  private:
182  JEquationPrivate* m_private;
183 
184 
185  };
186 };
192 extern "C"
193 {
194  JEQUATION_EXPORT magnes::JEquation* GetEquation();
195 
196 }
197 
198 #endif
size_t m_s2
Definition: jequation.h:180
size_t m_s1
Definition: jequation.h:178
void SetName(const std::string &name)
Definition: jequation.h:105
MAGNES_CORE_API std::ostream & operator<<(std::ostream &s, const Coordinate &c)
Definition: coordinate.h:269
the global magnes namespace
Definition: ccchequation.h:38
std::string Name() const
Definition: jequation.h:103
Parameter(const std::string &name, float value)
Definition: jequation.h:69
The base class for the computation of scalar coupling constants.
Definition: jequation.h:53
const std::vector< Parameter > & Set() const
Definition: jequation.h:99
Definition: molecule.h:44
ParameterSet()
Empty constructor.
Definition: jequation.h:95
void SetValue(float value)
Definition: jequation.h:78
float Value() const
Definition: jequation.h:80
const std::string & Name() const
Definition: jequation.h:76
Representation of a parameter in an empirical equation.
Definition: jequation.h:62
A set of parameters.
Definition: jequation.h:91
std::vector< Parameter > & Set()
Definition: jequation.h:101
void SetName(const std::string &name)
Definition: jequation.h:72
ParameterSet(const std::string &name)
Construct an empty parameter set with name n.
Definition: jequation.h:97
Representation of a conformer.
Definition: frame.h:33