Aether  0.0
Ionosphere-Thermosphere model
times.h
1 // Copyright 2020, the Aether Development Team (see doc/dev_team.md for members)
2 // Full license can be found in License.md
3 
4 #ifndef INCLUDE_TIMES_H_
5 #define INCLUDE_TIMES_H_
6 
7 /**************************************************************
8  *
9  * times.h:
10  *
11  * Functions that are assocuated with keeping track of time in
12  * Aether. Once central concept in Aether, is that time is stored as
13  * a double and is the number of seconds from January 1, 1965. This is
14  * arbitrary, and is derived from code developed by UCLA in the 1990s.
15  *
16  **************************************************************/
17 
18 #include <vector>
19 #include <string>
20 
21 class Times {
22 
23 public:
24 
25  /**************************************************************
26  \brief Initialize the Times class
27  **/
28  Times();
29 
30  /**************************************************************
31  \brief Increments the current time and derived variables
32 
33  Increments the current time, simulation time, and iStep.
34  Then derives a bunch of variables from there, in order to allow
35  users to use more than the time in seconds. This function should
36  only be called once per iteration at the end of advance.
37  **/
38  void increment_time();
39 
40  /**************************************************************
41  \brief Increments the intermediate/coupling time by input dt
42 
43  This increments the intermediate time (or coupling time) by
44  the input time. The intermediate time is set as the time in which
45  Aether should couple with any external models (in main). When
46  Aether is run in stand-alone mode, this doesn't really do much.
47 
48  \param dt amount of time to move the intermediate time forward.
49  **/
50  void increment_intermediate(double dt);
51 
52  /**************************************************************
53  \brief Displays the current time, elapsed time, and time to complete
54 
55  This displays the current time, the elapsed wall time, estimates
56  a time to completion (remaining_walltime) and displays that also.
57  **/
58  void display();
59 
60  /**************************************************************
61  \brief Sets the start, restart, and current times.
62 
63  This sets the start time, restart time, and current time to
64  the input time, and initializes iStep and dt, then calls
65  increment_time, which derives a bunch of other variables.
66 
67  \param itime year, month, day, hour, minute, second, millisecond vector
68  **/
69  void set_times(std::vector<int> itime);
70 
71  /**************************************************************
72  \brief Sets end time
73 
74  This simply ses the end time of the simulation from the input.
75 
76  \param itime year, month, day, hour, minute, second, millisecond vector
77  **/
78  void set_end_time(std::vector<int> itime);
79 
80  /**************************************************************
81  \brief Returns the current time in seconds since ref date
82  **/
83  double get_current();
84 
85  /**************************************************************
86  \brief Returns the end time in seconds since ref date
87  **/
88  double get_end();
89 
90  /**************************************************************
91  \brief Returns the current time as a string (year, month...)
92 
93  Returns the current time as a string of format YYYYMMDD_HHMMSS
94  **/
95  std::string get_YMD_HMS();
96 
97  /**************************************************************
98  \brief Returns the intermediate time in seconds since ref date
99  **/
100  double get_intermediate();
101 
102  /**************************************************************
103  \brief Returns dt
104 
105  dt is the delta-time between iterations in Aether.
106  **/
107  precision_t get_dt();
108 
109  /**************************************************************
110  \brief Returns current time in specific unit for planetary calc
111 
112  Return the current time as an orbit time, to allow for calculation
113  of a bunch of planetary characteristics. It's a JPL thing.
114  **/
115  precision_t get_orbittime();
116 
117  /**************************************************************
118  \brief Returns current time in Julian Days
119  **/
120  double get_julian_day();
121 
122  /**************************************************************
123  \brief Check to see if time just passed through dt gate.
124 
125  This function checks to see if the simulation has passed through
126  a time gate. By this, I mean that the user sets a dt_check in which
127  to do something. If the simulation passes through that dt_check,
128  then it will return a 1, else it will return a 0. It also returns
129  1 if the current time is the start time or restart time.
130 
131  \param dt_check Repetative delta-time to do a task
132 
133  **/
134  int check_time_gate(precision_t dt_check);
135 
136  /**************************************************************
137  \brief Calculates the delta time in the code.
138 
139  This calculates the delta-time in Aether for the current state.
140  At this moment, this is a stand-in code. In reality, we need to pass
141  in the grid, neutrals, ions, and inputs for calculation.
142  **/
143  void calc_dt();
144 
145  /**************************************************************
146  \brief Get the current time as an array
147  **/
148  std::vector<int> get_iCurrent();
149 
150 private:
151 
152  // -------------------------------------------------------------
153  // These variables are for keeping track of the time. All in seconds
154  // since reference time (except where noted).
155 
157  double start;
158 
160  double restart;
161 
163  double end;
164 
166  double current;
167 
169  double intermediate;
170 
172  double simulation;
173 
175  int64_t iStep;
176 
178  precision_t dt;
179 
180  // -------------------------------------------------------------
181  // Derived variables from the current time:
182 
184  std::vector<int> iCurrent;
185 
187  precision_t ut;
188 
190  precision_t orbittime;
191 
193  int year;
194  int month;
195  int day;
196  int hour;
197  int minute;
198  int second;
199  int milli;
200 
202  int jDay;
203 
205  double julian_day;
206 
208  std::string sYMD;
209 
211  std::string sHMS;
212 
214  std::string sYMD_HMS;
215 
216  // -------------------------------------------------------------
217  // Keeping track of walltime for the run:
218 
220  time_t sys_time_start;
221 
223  time_t sys_time_current;
224 
226  precision_t walltime;
227 };
228 
229 #endif // INCLUDE_TIMES_H_
Times
Definition: times.h:21