From c86a8c4bf6846fd911360209ad64488ccda8c41a Mon Sep 17 00:00:00 2001 From: Julian Quick Date: Tue, 27 Apr 2021 20:14:10 -0600 Subject: [PATCH 1/2] added alm log write statements in new helper function --- windse/ParameterManager.py | 7 ++++--- windse/helper_functions.py | 27 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/windse/ParameterManager.py b/windse/ParameterManager.py index db19934a..143f0e70 100644 --- a/windse/ParameterManager.py +++ b/windse/ParameterManager.py @@ -7,6 +7,7 @@ import __main__ import os import yaml +import warnings ### Get the name of program importing this package ### if hasattr(__main__,"__file__"): @@ -166,9 +167,9 @@ def Load(self, loc,updated_parameters=[]): ### Check if dolfin_adjoint is unnecessary or required ### optimizing = yaml_file.get("optimization",{}).get("control_types",None) is not None if optimizing and not self.dolfin_adjoint: - raise ValueError("Optimization setting provided but general:dolfin_adjoint is set to False") + warnings.warn("Optimization setting provided but general:dolfin_adjoint is set to False") elif not optimizing and self.dolfin_adjoint: - raise ValueError("general:dolfin_adjoint is set to True but no optimization parameters provided") + warnings.warn("general:dolfin_adjoint is set to True but no optimization parameters provided") # print(self.dolfin_adjoint) # for module in sys.modules: @@ -407,4 +408,4 @@ def tag_output(self, key, value, collective_output=None): ### Print the new dict ### # print(self.tagged_output) -windse_parameters = Parameters() \ No newline at end of file +windse_parameters = Parameters() diff --git a/windse/helper_functions.py b/windse/helper_functions.py index dff3f5f5..410e8398 100644 --- a/windse/helper_functions.py +++ b/windse/helper_functions.py @@ -363,6 +363,19 @@ def UpdateActuatorLineForce(problem, mpi_u_fluid_constant, simTime_id, dt, turb_ simTime = problem.simTime_list[simTime_id] + + fa = open(problem.aoa_files[turb_i], 'a') + fx = open(problem.force_files[turb_i][0], 'a') + fy = open(problem.force_files[turb_i][1], 'a') + fz = open(problem.force_files[turb_i][2], 'a') + + fa.write('%.5f, ' % (simTime)) + fx.write('%.5f, ' % (simTime)) + fy.write('%.5f, ' % (simTime)) + fz.write('%.5f, ' % (simTime)) + + + if verbose: print("Current Optimization Time: "+repr(simTime)+", Turbine #"+repr(turb_i)) sys.stdout.flush() @@ -497,10 +510,9 @@ def get_angle_between_vectors(a, b, n): real_cd[k] = problem.interp_drag(aoa, rdim[k]) # Write the aoa to a file for future reference - # fp.write('%.5f, ' % (aoa/np.pi*180.0)) + fa.write('%.5f, ' % (aoa/np.pi*180.0)) # fp.close() - return real_cl, real_cd, tip_loss @@ -760,6 +772,11 @@ def get_angle_between_vectors(a, b, n): # Find the component in the direction tangential to the blade tangential_actuator_force = np.dot(actuator_force, blade_unit_vec[:, 2]) + rotor_plane_force = np.dot(actuator_force, blade_unit_vec) + fx.write('%.5f, ' % (rotor_plane_force[0])) + fy.write('%.5f, ' % (rotor_plane_force[1])) + fz.write('%.5f, ' % (rotor_plane_force[2])) + # Multiply by the distance away from the hub to get a torque actuator_torque = tangential_actuator_force*rdim[k] @@ -767,6 +784,12 @@ def get_angle_between_vectors(a, b, n): rotor_torque_numpy_temp += actuator_torque ### Should this be an output? + + fx.close() + fy.close() + fz.close() + fa.close() + # Output the numpy version of rotor_torque problem.rotor_torque[turb_i] = rotor_torque_numpy_temp if rotor_torque_numpy_temp > 0: From b0726f6bc4c52302853be4f967547fc09e2128ee Mon Sep 17 00:00:00 2001 From: 99kilojoules Date: Mon, 3 May 2021 13:05:14 -0600 Subject: [PATCH 2/2] Needed to add line breaks in force log --- windse/WindFarmManager.py | 4 ++-- windse/helper_functions.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/windse/WindFarmManager.py b/windse/WindFarmManager.py index 6a200d5a..8f6e2bed 100644 --- a/windse/WindFarmManager.py +++ b/windse/WindFarmManager.py @@ -199,10 +199,10 @@ def PlotChord(self,show=False,filename="chord_profiles",power=None, bounds=None) lower.append(seg_chord/modifier) upper.append(max(min(seg_chord*modifier,max_chord),c_avg)) c_avg = (c_avg*k+seg_chord)/(k+1) - plt.plot(x,lower,"--r",label="opt_bounds") + plt.plot(x,lower,"--r",label="Optimization Boundaries") plt.plot(x,upper,"--r") else: - plt.plot(x,bounds[0][-self.blade_segments:],"--r",label="opt_bounds") + plt.plot(x,bounds[0][-self.blade_segments:],"--r",label="Optimization Boundaries") plt.plot(x,bounds[1][-self.blade_segments:],"--r") for i in range(self.numturbs): diff --git a/windse/helper_functions.py b/windse/helper_functions.py index 410e8398..94a7f310 100644 --- a/windse/helper_functions.py +++ b/windse/helper_functions.py @@ -785,6 +785,10 @@ def get_angle_between_vectors(a, b, n): + fx.write('\n') + fy.write('\n') + fz.write('\n') + fa.write('\n') fx.close() fy.close() fz.close()