Skip to content

Commit 2b8dc4b

Browse files
committed
Updated start time
1 parent 98ce6ba commit 2b8dc4b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

rocketpy/simulation/monte_carlo.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import h5py
88
import numpy as np
99
import simplekml
10-
from multiprocess import JoinableQueue, Lock, Process
10+
from multiprocess import Lock, Process
1111
from multiprocess.managers import BaseManager
1212

1313
from rocketpy import Function
@@ -296,12 +296,12 @@ def __run_in_parallel(self, append, light_mode, n_workers=None):
296296
-------
297297
None
298298
"""
299+
parallel_start = time()
299300
processes = []
300301

301302
if n_workers is None:
302303
n_workers = os.cpu_count()
303304

304-
parallel_start = time()
305305

306306
with MonteCarloManager() as manager:
307307
# initialize queue
@@ -353,7 +353,7 @@ def __run_in_parallel(self, append, light_mode, n_workers=None):
353353
pass # initialize file
354354

355355
# Initialize simulation counter
356-
sim_counter = manager.SimCounter(idx_i, self.number_of_simulations)
356+
sim_counter = manager.SimCounter(idx_i, self.number_of_simulations, parallel_start)
357357

358358
print("\nStarting monte carlo analysis", end="\r")
359359
print(f"Number of simulations: {self.number_of_simulations}")
@@ -1168,19 +1168,18 @@ class MonteCarloManager(BaseManager):
11681168
def __init__(self):
11691169
super().__init__()
11701170
self.register('Lock', Lock)
1171-
self.register('JoinableQueue', JoinableQueue)
11721171
self.register('SimCounter', SimCounter)
11731172
self.register('StochasticEnvironment', StochasticEnvironment)
11741173
self.register('StochasticRocket', StochasticRocket)
11751174
self.register('StochasticFlight', StochasticFlight)
11761175

11771176

11781177
class SimCounter:
1179-
def __init__(self, initial_count, n_simulations):
1178+
def __init__(self, initial_count, n_simulations, parallel_start):
11801179
self.count = initial_count
11811180
self.n_simulations = n_simulations
11821181
self._last_print_len = 0 # used to print on the same line
1183-
self.initial_time = time()
1182+
self.initial_time = parallel_start
11841183

11851184
def increment(self):
11861185
if self.count >= self.n_simulations:

0 commit comments

Comments
 (0)