TUDelft-DataDrivenControl / OFF

Working repo for a dynamic parametric wake toolbox which combines OnWaRDS, FLORIDyn and FLORIS
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

Parallelise the wake calculation #10

Open MarcusBecker-GitHub opened 9 months ago

MarcusBecker-GitHub commented 9 months ago

As of now, one wind farm solver with one wake model (e.g. FLORIS) is sequentially used to evaluate the farm wakes at each turbine. Mathematically, this can happen in parallel. The current issue is that all turbines interface the wake solver and thus the same FLORIS model.

One way to circumvent that would be to create a pool of wake solvers and then queue the turbines to be solved by one of the solvers. This should not include too many changes, as the wind farm object is owned by the off object and not by the solver.

Proposed pseudocode:

# in off.py
from multiprocessing import Pool

# ...
pool = Pool(processes=4)
# ...

for t in np.arange(self.settings_sim['time start'],
                           self.settings_sim['time end'],
                           self.settings_sim['time step']):

    # build wake solver input
    results = pool.apply_async(get_measurements, pool_inputs)

   # Unpack results
    uv_r, uv_op, m_tmp = results

    # Apply results
    for idx, tur in enumerate(self.wind_farm.turbines):
        pow_t[idx, :] = tur.calc_power(...)
        m_tmp['pow'] = pow_t[idx, :]
        # ...

    # ...

# Simulation end
pool.close()

Alternatively this could also happen in the wake solver. It seems intuitive to build a sequential and parallel wake solver, but this would require moving the entire prediction part of the simulation loop in ´´off.py´´ into the wake solver. Might also not be the worst option.