Develop and Download Open Source Software

Browse Subversion Repository

Contents of /Conograph/trunk/src/lattice_symmetry/LatticeFigureOfMeritToDisplay.hh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 33 - (show annotations) (download) (as text)
Wed Sep 7 04:38:51 2016 UTC (7 years, 6 months ago) by rtomiyasu
File MIME type: text/x-c++hdr
File size: 11677 byte(s)
The output format for base-centered monoclinic cells was corrected.
1 /*
2 * The MIT License
3
4 Conograph (powder auto-indexing program)
5
6 Copyright (c) <2012> <Ryoko Oishi-Tomiyasu, KEK>
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 *
26 */
27 #ifndef LatticeFigureOfMeritToDisplay_HH_
28 #define LatticeFigureOfMeritToDisplay_HH_
29
30 #include <map>
31 #include "LatticeFigureOfMeritZeroShift.hh"
32 #include "../utility_data_structure/range.hh"
33 #include "../qc/reflection_conditions.hh"
34
35
36 // Class for outputting information about a lattice in IGOR file.
37 class LatticeFigureOfMeritToDisplay
38 {
39 private:
40 LatticeFigureOfMeritZeroShift m_latfom;
41
42 vector<QData> m_qdata;
43 vector< multimap<Double, vector<HKL_Q>::const_iterator> > m_associated_hkl_tray;
44 vector<HKL_Q> m_cal_hkl_tray;
45
46 // The size of the following arrays equals zero or m_figures_of_merit.m_num_ref_figure_of_merit.
47 vector< VecDat3<Int4> > m_hkl_to_fit;
48 vector<bool> m_fix_or_fit_flag; // 0:fix, 1:fit.
49
50 // If this is negative value, only the reflection conditions derived from the Bravais type are considered.
51 Int4 m_type_of_reflection_conditions;
52
53 // for GUI
54 bool m_showsTicks;
55
56 public:
57 void putPeakPosToFit(const ControlParam& cdata, Vec_DP& cal_q_tray, Vec_DP& cal_pos_tray) const;
58 void putStandardMillerIndicesToFit(vector< VecDat3<Int4> >& hkl_to_fit,
59 vector<bool>& fix_or_fit_flag) const;
60
61 LatticeFigureOfMeritToDisplay();
62 ~LatticeFigureOfMeritToDisplay(){};
63
64 inline const eBravaisType& enumBravaisType() const { return m_latfom.enumBravaisType(); };
65 inline const LatticeFigureOfMeritZeroShift& putLatticeFigureOfMerit() const { return m_latfom; };
66 inline const vector<HKL_Q>& putCalMillerIndices() const { return m_cal_hkl_tray; };
67 inline const vector< multimap<Double, vector<HKL_Q>::const_iterator> >& putAssociatedMillerIndices() const { return m_associated_hkl_tray; };
68
69 // axis1: axis of the argument lattice constants for Monoclinic(C) or Orthorhombic(C).
70 // axis2: axis of the argument lattice constants for Rhombohedral.
71 inline ZErrorMessage setLatticeConstantsDegree(const eBravaisType& ecys,
72 const eABCaxis& axis1,
73 const eRHaxis& axis2,
74 const VecDat3<Double>& length_axis,
75 const VecDat3<Double>& angle_axis) { return m_latfom.setLatticeConstantsDegree(BravaisType(ecys, axis1, axis2), length_axis, angle_axis); };
76 inline ZErrorMessage setPeakShiftParamDegree(const ePeakShiftFunctionType& type,
77 const Double& wave_length,
78 const vector<ZParawError>& peak_shift_param_deg, // The errors are not used in this method.
79 const PeakPosData& pdata);
80 inline void reduceLatticeConstants();
81
82 inline void putOptimizedLatticeConstantsDegree(const eABCaxis& axis1,
83 const eRHaxis& axis2,
84 VecDat3<Double>& length_axis,
85 VecDat3<Double>& angle_axis) { m_latfom.putOptimizedLatticeConstantsDegree(axis1, axis2, length_axis, angle_axis); };
86
87 // axis1: axis of the argument lattice constants for Monoclinic(C) or Orthorhombic(C).
88 // axis2: axis of the argument lattice constants for Rhombohedral.
89 inline void putReducedLatticeConstantsDegree(const eABCaxis& axis1,
90 const eRHaxis& axis2,
91 VecDat3<Double>& length_axis,
92 VecDat3<Double>& angle_axis) { m_latfom.putReducedLatticeConstantsDegree(axis1, axis2, length_axis, angle_axis); };
93
94 inline const Double& putWaveLength() const { return m_latfom.putWaveLength(); };
95 inline const ePeakShiftFunctionType& putPeakShiftFunctionType() const { return m_latfom.putPeakShiftFunctionType(); };
96 inline vector<ZParawError> putPeakShiftParamDegree() const { return m_latfom.putPeakShiftParamDegree(); };
97
98 inline const vector<QData>& putQDataModifiedWithNewPeakShiftParam() const { return m_qdata; };
99
100 inline void setDeWolffFigureOfMerit(const Int4& num_ref_figure_of_merit){ m_latfom.setDeWolffFigureOfMerit(num_ref_figure_of_merit, m_type_of_reflection_conditions, m_qdata); };
101 inline void setFigureOfMerit(const Int4& num_ref_figure_of_merit){ m_latfom.setFigureOfMerit(num_ref_figure_of_merit, m_qdata); };
102
103 void setTypeOfSystematicAbsences(const Int4& arg);
104 inline string putShortStringTypeOfSystematicAbsences() const
105 {
106 return putInformationOnReflectionConditions(this->putLatticeFigureOfMerit().putBravaisType(), m_type_of_reflection_conditions).putShortStringType();
107 };
108 inline const string& putStringTypeOfSystematicAbsences() const
109 {
110 return putInformationOnReflectionConditions(this->putLatticeFigureOfMerit().putBravaisType(), m_type_of_reflection_conditions).putStringType();
111 };
112 inline const string& putStringReflectionConditions() const
113 {
114 return putInformationOnReflectionConditions(this->putLatticeFigureOfMerit().putBravaisType(), m_type_of_reflection_conditions).putStringConditions();
115 };
116 inline const DataReflectionConditions& putDataOnReflectionConditions() const
117 {
118 return putInformationOnReflectionConditions(this->putLatticeFigureOfMerit().putBravaisType(), m_type_of_reflection_conditions);
119 };
120
121
122 // Resets m_associated_hkl_tray and q-values in m_cal_hkl_tray.
123 void resetQValuesInRange(const Int4& num_fit_data);
124 // Resets m_associated_hkl_tray and m_cal_hkl_tray.
125 void resetMillerIndicesInRange(const Int4& num_fit_data);
126 // Resets m_hkl_to_fit and m_fix_or_fit_flag.
127 void resetMillerIndicesToFit() { putStandardMillerIndicesToFit(m_hkl_to_fit, m_fix_or_fit_flag); };
128
129 inline ZErrorMessage setFittingIDs(const vector<bool>& arg);
130 inline const vector<bool>& putFittingIDs() const { return m_fix_or_fit_flag; };
131 inline ZErrorMessage setMillerIndicesToFit(const vector< VecDat3<Int4> >& arg);
132 inline const vector< VecDat3<Int4> >& putMillerIndicesToFit() const { return m_hkl_to_fit; };
133
134 // Return peak positions for this lattice candidate.
135 void putCalculatedPeakPosInRange(const ControlParam& cdata, Vec_DP& cal_pos_tray) const;
136
137 // Returned value
138 // > 1 : Optimization has succeeded at least twice. (The members m_hkl_to_fit and m_fix_or_fit_flag are changed.)
139 // > 0 : Optimization has succeeded. (Lattice constants are changed.)
140 // 0 : Optimization has failed.
141 Int4 fitLatticeParameter(const PeakPosData& pdata, const vector<etype_ID>& fitflag,
142 const Int4& Max_ITNUM,
143 const Double& limiter);
144
145 // Output indexing results.
146 void printIndexingResult(const ControlParam& cdata,
147 const PeakPosData& pdata,
148 const Int4& label_start0,
149 ostream* os) const;
150
151 // For GUI.
152 const vector<bool> &getref_m_fix_or_fit_flag() const {return m_fix_or_fit_flag;}
153 vector<bool> &getref_m_fix_or_fit_flag() {return m_fix_or_fit_flag;}
154 const vector<VecDat3<Int4> > &getref_m_hkl_to_fit() const {return m_hkl_to_fit;}
155 vector<VecDat3<Int4> > &getref_m_hkl_to_fit() {return m_hkl_to_fit;}
156 const LatticeFigureOfMeritZeroShift &getref_m_latfom() const {return m_latfom;}
157 LatticeFigureOfMeritZeroShift &getref_m_latfom() {return m_latfom;}
158 const vector<QData> &getref_m_qdata() const {return m_qdata;}
159 vector<QData> &getref_m_qdata() {return m_qdata;}
160 const vector< multimap<Double, vector<HKL_Q>::const_iterator> > &getref_m_associated_hkl_tray() const {return m_associated_hkl_tray;}
161 vector< multimap<Double, vector<HKL_Q>::const_iterator> > &getref_m_associated_hkl_tray() {return m_associated_hkl_tray;}
162 const vector<HKL_Q> &getref_m_cal_hkl_tray() const {return m_cal_hkl_tray;}
163 vector<HKL_Q> &getref_m_cal_hkl_tray() {return m_cal_hkl_tray;}
164 const bool &getref_m_showsTicks() const {return m_showsTicks;}
165 bool &getref_m_showsTicks() {return m_showsTicks;}
166 };
167
168
169 inline ZErrorMessage LatticeFigureOfMeritToDisplay::setFittingIDs(const vector<bool>& arg)
170 {
171 if( arg.size() != m_associated_hkl_tray.size() )
172 {
173 return ZErrorMessage(ZErrorArgmentSize, __FILE__, __LINE__, __FUNCTION__);
174 }
175 m_fix_or_fit_flag = arg;
176 return ZErrorMessage();
177 }
178
179 inline ZErrorMessage LatticeFigureOfMeritToDisplay::setMillerIndicesToFit(const vector< VecDat3<Int4> >& arg)
180 {
181 if( arg.size() != m_associated_hkl_tray.size() )
182 {
183 return ZErrorMessage(ZErrorArgmentSize, __FILE__, __LINE__, __FUNCTION__);
184 }
185 m_hkl_to_fit = arg;
186 return ZErrorMessage();
187 };
188
189
190 inline ZErrorMessage LatticeFigureOfMeritToDisplay::setPeakShiftParamDegree(
191 const ePeakShiftFunctionType& type,
192 const Double& wave_length,
193 const vector<ZParawError>& peak_shift_param_deg,
194 const PeakPosData& pdata)
195 {
196 static const Double RadDeg = PI() / 180.0;
197
198 vector<ZParawError> peak_shift_param_rad = peak_shift_param_deg;
199 for(vector<ZParawError>::iterator it=peak_shift_param_rad.begin(); it<peak_shift_param_rad.end(); it++)
200 {
201 *it *= RadDeg;
202 }
203 return m_latfom.setPeakShiftParamRadian(VCData::putPeakQData(), type, wave_length, peak_shift_param_rad, pdata,
204 VCData::putPeakQData().size(), m_qdata);
205 };
206
207
208 inline VecDat3<Int4> product_hkl(const VecDat3<Int4>& lhs, const NRMat<Int4>& rhs)
209 {
210 assert( rhs.nrows() >= 3 && rhs.ncols() == 3 );
211
212 VecDat3<Int4> ans;
213 ans[0] = lhs[0]*rhs[0][0] + lhs[1]*rhs[1][0] + lhs[2]*rhs[2][0];
214 ans[1] = lhs[0]*rhs[0][1] + lhs[1]*rhs[1][1] + lhs[2]*rhs[2][1];
215 ans[2] = lhs[0]*rhs[0][2] + lhs[1]*rhs[1][2] + lhs[2]*rhs[2][2];
216 return ans;
217 }
218
219
220 inline void LatticeFigureOfMeritToDisplay::reduceLatticeConstants()
221 {
222 NRMat<Int4> trans_mat;
223 // trans_mat * m_latfom.m_S_optimized.first(new) * transpose(trans_mat) = m_latfom.m_S_optimized.first(old).
224 m_latfom.reduceLatticeConstants(trans_mat);
225
226 for(vector<HKL_Q>::iterator it=m_cal_hkl_tray.begin(); it<m_cal_hkl_tray.end(); it++)
227 {
228 it->setHKL( product_hkl(it->HKL(), trans_mat) );
229 }
230
231 for(vector< VecDat3<Int4> >::iterator it=m_hkl_to_fit.begin(); it<m_hkl_to_fit.end(); it++)
232 {
233 *it = product_hkl(*it, trans_mat);
234 }
235 };
236
237 inline bool cmpDeWolff(const LatticeFigureOfMeritToDisplay& lhs, const LatticeFigureOfMeritToDisplay& rhs)
238 {
239 return lhs.putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff()
240 > rhs.putLatticeFigureOfMerit().putFiguresOfMerit().putFigureOfMeritWolff();
241 }
242
243
244 #endif /*LatticeFigureOfMeritToDisplay_HH_*/

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26