Skip to content
Snippets Groups Projects
Commit 13f03fec authored by Mikkel Friis-Møller's avatar Mikkel Friis-Møller
Browse files

Merge branch 'plot_cost_decrease' into 'master'

Show cost decrease in PlotComp

See merge request !24
parents 78234fcf 58a21982
No related branches found
No related tags found
1 merge request!94Handle disabled mpi
...@@ -56,19 +56,20 @@ class PlotComp(ExplicitComponent): ...@@ -56,19 +56,20 @@ class PlotComp(ExplicitComponent):
def compute(self, inputs, outputs): def compute(self, inputs, outputs):
x = inputs['turbineX'] x = inputs['turbineX']
y = inputs['turbineY'] y = inputs['turbineY']
cost = inputs['cost'][0]
if not hasattr(self, "initial"): if not hasattr(self, "initial"):
self.initial = np.array([x, y]).T self.initial = np.array([x, y]).T, cost
cost = inputs['cost']
self.history = [(x.copy(), y.copy())] + self.history[:self.memory] self.history = [(x.copy(), y.copy())] + self.history[:self.memory]
boundary = inputs['boundary'] boundary = inputs['boundary']
self.init_plot(boundary) self.init_plot(boundary)
plt.title(cost) plt.title("%f (%.2f%%)"%(cost, (self.initial[1]-cost)/self.initial[1]*100))
history_arr = np.array(self.history) history_arr = np.array(self.history)
for i, c, x_, y_ in zip(range(len(x)), self.colors, x, y): for i, c, x_, y_ in zip(range(len(x)), self.colors, x, y):
if self.plot_initial: if self.plot_initial:
plt.plot([self.initial[i, 0], x_], [self.initial[i, 1], y_], '-', color=c, lw=1) plt.plot([self.initial[0][i, 0], x_], [self.initial[0][i, 1], y_], '-', color=c, lw=1)
plt.plot(history_arr[:, 0, i], history_arr[:, 1, i], '.--', color=c, lw=1) 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_, 'o', color=c, ms=5)
plt.plot(x_, y_, 'x' + 'k', ms=4) plt.plot(x_, y_, 'x' + 'k', ms=4)
......
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