kamemontecarlo.h
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #ifndef KAMEMONTECARLO_H_
15 #define KAMEMONTECARLO_H_
16 
17 #include "primarydriver.h"
18 #include "dummydriver.h"
19 #include "xwavengraph.h"
20 #include <fftw3.h>
21 
22 class XScalarEntry;
23 class MonteCarlo;
24 class Ui_FrmMonteCarlo;
26 
27 class XMonteCarloDriver : public XDummyDriver<XPrimaryDriver> {
28 public:
29  XMonteCarloDriver(const char *name, bool runtime,
30  Transaction &tr_meas, const shared_ptr<XMeasure> &meas);
31  //! usually nothing to do
32  virtual ~XMonteCarloDriver();
33  //! show all forms belonging to driver
34  virtual void showForms();
35 
36  struct Payload : public XPrimaryDriver::Payload {
37  Payload() : m_fftlen(-1) {}
38  private:
39  friend class XMonteCarloDriver;
40  shared_ptr<MonteCarlo> m_loop, m_store;
41  int m_fftlen;
42  fftw_complex *m_pFFTin[3];
43  fftw_complex *m_pFFTout[3];
44  fftw_plan m_fftplan[3];
45 
46  long double m_sumDU, m_sumDS, m_sumDUav;
47  long double m_testsTotal;
48  double m_flippedTotal;
49  double m_dU;
50  double m_DUav, m_Mav;
51  double m_lastTemp;
52  //! along field direction.
53  double m_lastField, m_lastMagnetization;
54  };
55 protected:
56  //! Starts up your threads, connects GUI, and activates signals.
57  virtual void start();
58  //! Shuts down your threads, unconnects GUI, and deactivates signals
59  //! This function may be called even if driver has already stopped.
60  virtual void stop();
61 
62  //! This function will be called when raw data are written.
63  //! Implement this function to convert the raw data to the record (Payload).
64  //! \sa analyze()
65  virtual void analyzeRaw(RawDataReader &reader, Transaction &tr) throw (XRecordError&);
66  //! This function is called after committing XPrimaryDriver::analyzeRaw() or XSecondaryDriver::analyze().
67  //! This might be called even if the record is invalid (time() == false).
68  virtual void visualize(const Snapshot &shot);
69 private:
70  shared_ptr<XDoubleNode> m_targetTemp;
71  shared_ptr<XDoubleNode> m_targetField;
72  shared_ptr<XDoubleNode> m_hdirx;
73  shared_ptr<XDoubleNode> m_hdiry;
74  shared_ptr<XDoubleNode> m_hdirz;
75  shared_ptr<XUIntNode> m_L;
76  shared_ptr<XDoubleNode> m_cutoffReal;
77  shared_ptr<XDoubleNode> m_cutoffRec;
78  shared_ptr<XDoubleNode> m_alpha;
79  shared_ptr<XDoubleNode> m_minTests;
80  shared_ptr<XDoubleNode> m_minFlips;
81  shared_ptr<XTouchableNode> m_step;
82  shared_ptr<XComboNode> m_graph3D;
83  shared_ptr<XScalarEntry> m_entryT, m_entryH,
84  m_entryU, m_entryC, m_entryCoT,
85  m_entryS, m_entryM, m_entry2in2, m_entry1in3;
86 
87  xqcon_ptr m_conLength, m_conCutoffReal, m_conCutoffRec, m_conAlpha,
88  m_conTargetTemp, m_conTargetField,
89  m_conHDirX, m_conHDirY, m_conHDirZ, m_conMinTests, m_conMinFlips, m_conStep,
90  m_conGraph3D;
92  shared_ptr<XWaveNGraph> m_wave3D;
93  void execute(int flips, long double tests);
94  void onTargetChanged(const Snapshot &shot, XValueNodeBase *);
95  void onGraphChanged(const Snapshot &shot, XValueNodeBase *);
96  void onStepTouched(const Snapshot &shot, XTouchableNode *);
97  shared_ptr<XListener> m_lsnTargetChanged, m_lsnStepTouched, m_lsnGraphChanged;
98  shared_ptr<XStatusPrinter> m_statusPrinter;
99 };
100 
101 #endif /*KAMEMONTECARLO_H_*/

Generated for KAME4 by  doxygen 1.8.3