Skip to content
Snippets Groups Projects
Commit 2113db42 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

plotting parameters updated

parent 3096c13d
No related branches found
No related tags found
1 merge request!94Handle disabled mpi
......@@ -57,8 +57,8 @@ class DummyCost(ExplicitComponent):
J['cost', 'turbineY'] = (2 * y - 2 * np.array(self.optimal)[:, 1])
class DummyCostPlotComp(PlotComp):
def __init__(self, optimal):
super().__init__()
def __init__(self, optimal, memory=10):
super().__init__(memory)
self.optimal = optimal
def init_plot(self, boundary):
......
......@@ -9,10 +9,9 @@ class PlotComp(ExplicitComponent):
"""
colors = ['b', 'r', 'm', 'c', 'g', 'y', 'orange', 'indigo', 'grey'] * 100
def __init__(self, memory=10, plot_every=5):
def __init__(self, memory=10):
ExplicitComponent.__init__(self)
self.memory = memory
self.plot_every = plot_every
self.history = []
self.counter = 0
......@@ -47,20 +46,17 @@ class PlotComp(ExplicitComponent):
x = inputs['turbineX']
y = inputs['turbineY']
cost = inputs['cost']
if self.history:
self.history = [(x.copy(), y.copy())] + self.history[:self.memory]
else:
self.history = [(x.copy(), y.copy())]
if self.counter % self.plot_every == 0:
boundary = inputs['boundary']
self.init_plot(boundary)
plt.title(cost)
history_arr = np.array(self.history)
for i, c, x_, y_ in zip(range(len(x)), self.colors, x, y):
plt.plot(history_arr[:, 0, i], history_arr[:, 1, i], '.-', color=c, lw=1)
plt.plot(x_, y_, 'o', color=c, ms=5)
plt.plot(x_, y_, 'x' + 'k', ms=4)
plt.pause(.01)
self.history = [(x.copy(), y.copy())] + self.history[:self.memory]
boundary = inputs['boundary']
self.init_plot(boundary)
plt.title(cost)
history_arr = np.array(self.history)
for i, c, x_, y_ in zip(range(len(x)), self.colors, x, y):
plt.plot(history_arr[:, 0, i], history_arr[:, 1, i], '.-', color=c, lw=1)
plt.plot(x_, y_, 'o', color=c, ms=5)
plt.plot(x_, y_, 'x' + 'k', ms=4)
plt.pause(.01)
self.counter += 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment