From 0677f7a441da010c245ee3168a706a0019e00c68 Mon Sep 17 00:00:00 2001 From: bayc Date: Fri, 5 Dec 2025 11:28:23 -0700 Subject: [PATCH 01/11] adding del_tower_base surrogate load function --- ard/farm_loads/__init__.py | 1 + ard/farm_loads/surrogate_load_functions.py | 65 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 ard/farm_loads/__init__.py create mode 100644 ard/farm_loads/surrogate_load_functions.py diff --git a/ard/farm_loads/__init__.py b/ard/farm_loads/__init__.py new file mode 100644 index 00000000..a39af5eb --- /dev/null +++ b/ard/farm_loads/__init__.py @@ -0,0 +1 @@ +from . import surrogate_load_functions \ No newline at end of file diff --git a/ard/farm_loads/surrogate_load_functions.py b/ard/farm_loads/surrogate_load_functions.py new file mode 100644 index 00000000..2b81ad3c --- /dev/null +++ b/ard/farm_loads/surrogate_load_functions.py @@ -0,0 +1,65 @@ +import numpy as np + +def tansig(x): + return 2 / (1 + np.exp(-2 * x)) - 1 + +def mapminmax_apply(x, settings): + return (x - settings['xoffset'][:, np.newaxis]) * settings['gain'][:, np.newaxis] + settings['ymin'] + +def mapminmax_reverse(y, settings): + return (y - settings['ymin']) / settings['gain'] + settings['xoffset'] + +def ANN_DEL_TowerBase(x1): + x1 = np.array(x1, dtype=np.float64) + if x1.ndim == 1: + x1 = x1.reshape(1, -1) + if x1.shape[1] != 10: + raise ValueError("Input must have shape (Q, 10)") + + # Normalize input + minInputs = np.array([3.36093, 3.43696, 3.36454, 3.41895, 8.07273, 8.23081, 8.67988, 8.44285, -30, 60]) + maxInputs = np.array([14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100]) + x1 = (x1 - minInputs) / (maxInputs - minInputs) + x1 = x1.T # (10, Q) + + # Preprocessing settings + x1_step1 = { + 'xoffset': np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), + 'gain': np.array([2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2]), + 'ymin': -1 + } + + y1_step1 = { + 'ymin': -1, + 'gain': 2.00004639898127, + 'xoffset': 2.31989524333902e-05 + } + + # Neural net weights (Layer 1 and 2) + b1 = np.array([ + -0.84162497711391714983,3.2926011373061605525,-3.5555455227097665372,-2.6479150716657304798,0.084908405569389278078,0.88102627456951254636,2.9098095957856964233,-1.5365347904503441345,0.42826877638142596405,3.7171892968014179637,-1.1267062983954521105,-3.1692161198502097896,0.44862185363865647592,0.0059798061670441465809,0.083920952379510360686,0.84092501379816608775,2.1711005707576713775,-4.2343657978014039855,-3.1293738202409504545,0.8873338206250047655,2.2666187777019515259,-0.62458140282536833698,-0.23835990419030628207,0.98971293975353968886,-2.1000912255506865023,-3.5606715080021755782,0.90417012266854923652,3.5767824884756058701,1.5345881333002955316,2.3094900541204097522 + ]) + + b2 = -2.3006747078844167476 + + IW1_1 = np.array([ + [-0.73314577044910178572,2.8287129130879797856,1.5877100060823403638,-0.41655991975409656369,0.097273890561228509855,0.76547073400483855998,-1.2822206037597951855,-1.3358392133678875791,-0.75065359840991330298,0.64663836274125341408],[1.5248642827357874463,-3.2314794316994297496,1.7278966231683206001,-0.30298572995397865526,0.72700476184016593617,-2.4564350290640657448,1.2808746935876647033,1.0053487209660716406,-0.054567809167083515531,2.7209768015275499486],[0.28835782282312688585,0.25196266795202981736,1.5602359578309927812,-3.0230108648302662644,-0.46104540051838283077,-2.5096224768534929339,1.8853499774504214326,-1.8512802123437130941,-0.0072108241588582930662,-0.23041967859359976933],[-0.77415367781163335614,3.7163062420508929939,-1.7509315664897189269,2.2506471323660499628,1.3290157563979454469,1.668059995930878614,-1.656422715963739023,-1.7085589114292070168,0.17422791589944844337,-3.6101746277618049774],[-1.5303513485698256869,-2.2748699140834407473,-0.91430462986787142121,1.7031083422226245272,-1.0828816400584695412,-0.98542555894232819469,0.1037276115815981975,1.7918445566763228083,-0.53784741045856254704,-0.65362886661162244994],[0.86522561103239303826,-1.8979878431754679813,-2.3638324849762319957,0.25618629740205128842,-0.059741699719734336904,0.10475601801469008878,0.35154240163984706857,1.2612971924108209443,0.6365349018892197952,-0.38892026926383943541],[-0.79717951130863318188,-1.7866528049116900956,2.4630215876678649423,-0.63913856292888571176,-1.3893773844656016614,2.7079192256023270069,-0.29125661831644727995,0.13478783801792221242,-0.44499658388473051218,3.9724902927789829121],[-2.1468840572278589107,0.9352703755387399287,0.10132770290081988263,1.6253429772440892709,-1.5216428365117817822,0.34863189459131382897,0.78567121687563556964,0.45414027770947434925,-1.9967742903415643951,0.0075970659915833233314],[-1.9622237832898525856,-0.5196275506754268747,-0.49067931899208472313,1.2703957847195881392,-1.8868740078256549531,-0.20321123936136653576,0.0068393333651150496968,1.7858073874806812409,0.73084644335656956393,0.25064528334787483654],[-0.16962473066216168793,-0.4820412910738208212,-2.6667827849934657714,0.26643678314280849762,-0.36396044205020244844,0.70354451187386890521,-1.5070895182316543792,0.64104650725093792474,-0.097743213540430612385,0.23728513777661014439],[-2.0410554283327249081,2.2409875745842300354,-3.3692409145696964323,1.7992726503941134375,3.3360986881249572455,-5.2815551713305204373,-1.3296212797003796879,1.2217429384131801573,-0.841507297175366209,0.13936158729076444929],[0.59573552422161712983,1.0939268284690140121,-0.24821226448753863636,0.90249206043346508199,0.048884521935790486991,-1.4927503391566487867,0.58494801191213108282,0.40293803933450045296,0.17579573810353754659,-2.2565382839985974606],[-3.003217538438221812,0.16689719881148923353,-1.2072341549677467754,2.0989368812931874508,-2.68828044483559081,0.089789187146049623256,-0.16780514782287364595,2.2298591801516303157,1.0816517634306781481,0.26847677909972939014],[2.6007224902676857603,-1.5841599436197115747,1.8033171593410857181,2.0662802370864552515,3.2229726791544019981,-2.742900728157287471,-3.2680040921810036281,0.020717209114053735525,-0.28595515157999523703,0.88902634377574718538],[-0.067806483816461329828,-0.57044263506227277372,1.1596014169837842722,0.22113257571278469027,0.025387590261853096307,-0.49286048374576491016,0.54304076803663392514,0.71064831385637960981,-0.10417223206974035588,-0.0025451527067482113478],[1.9733901389574612928,-3.2211131674174855455,1.1553484290512952004,-0.32229981685833380967,0.75261550666368293161,0.45250230577624950268,-1.1797606942277811815,0.49268093789963707252,0.055928184884686579781,-0.6466276570214183339],[2.1847194209233151696,7.4799445854895623143,1.5008151177392070608,-3.3893475854617975962,2.8026167156034351713,2.2073081660885587318,-1.059301959052601827,-3.9302991003224576616,-0.31168274003645601855,1.0023442035188014909],[-1.0012822675596795285,3.7786570396212719736,-1.5391187983334853051,1.5082231272932171695,0.5076885950058169783,2.0380125949109095806,-1.3192904728872731912,-1.4180004251489104483,0.12633077863470865143,-5.0929504755238381719],[-0.18304627197124528903,1.3400325149043699202,-0.89837235922567637569,-0.42078675394242837093,-0.33093212532440458018,-0.7408115596344096998,0.084676027605090173345,-0.98978975904575450251,0.21340927653231867023,-3.1407006287918259879],[2.5193387728473868314,-3.821493486297629083,1.232898839455989437,-0.41211507135204644703,0.93699545365185632484,0.36778373291199067951,-1.2594672431583939787,0.21790666959494661703,0.034140035264000945237,-0.60795236236146654729],[1.3082123553016988815,-3.4381035623023232795,2.7517699733229936676,-0.90629246020718257082,-1.2583091138186555114,-0.20045348812031213437,2.3224016497084756239,2.427759365760023158,-0.48742028493485195506,-0.43576489225969350372],[2.0247588002476799574,-5.7672863071503455146,2.9059326525086923709,-3.0885347866530961092,1.1718578695820622837,-1.1999946584458376364,0.50100566576652905137,-0.015360673044539016607,0.10151112197513319224,0.4356303017492557661],[-0.93393218008519962581,0.64171898024523155168,1.023475356251981605,0.76994444322229005362,0.0017456347202525939258,-0.68139090263893797861,0.61126408278564436927,0.81643466536731568173,0.014151016775331910422,-0.086222718181227217538],[1.8183996949330099024,-1.7967012399631754338,-2.7511476216865724531,-0.51109837604499930297,0.79887842815691212373,0.27193910857010389348,-0.1902934397636798225,0.82527332004905529228,0.65955179319892687229,-0.16076368288437462017],[-1.2246223321522089478,-0.69509471386913646018,-0.42086785651448577195,-0.49097759089980991254,-0.4865173574821159419,0.28812302580508780681,-0.045462622534334709568,0.093102031617319419565,0.19333531890690489052,0.012094259414969908695],[-0.54101497318564562011,1.2388363152547523516,-0.30955098884267412407,-1.392671060071018152,-0.41859130758748908097,-1.317798628211867662,0.78919075197092092289,-2.0879724454419670288,0.097897549005229261843,-0.14961949963903720118],[1.4177445562189072703,-0.82515637413414044676,0.88588242220425783557,-0.34037545844659078398,0.31647122672771083041,-0.23094740010168765543,0.22799798175246874243,0.095345910302176886675,-0.97966442188203683994,-0.0092327981091944264641],[-2.2112173391171525694,-1.8611402239423604499,-2.3948251375710736255,2.1189191474442701235,-2.4741654686139198382,0.88603393775006400457,4.1079702530789621306,-2.9367523072645185245,1.1592749369028840789,1.3701901834073804132],[0.93143002684612163922,-0.14344885948265617692,1.1995637416196398561,0.28328117071913810898,0.45140818370239166324,-0.75852423832135040804,0.38185990585530588115,0.54079499622638393941,0.044295733610979950989,-0.037952765478541115873],[0.19243565191640349399,-1.4366255458599905825,1.1866271182270113904,-0.48875760449992750045,-0.70944926486675308208,0.36540425943677817822,0.84621843351843117897,2.0413312531345848555,-0.18591285470335938701,-0.56987556083528989603] + ]) + + LW2_1 = np.array([ + -1.5215356135284230366,-1.6873883124842390391,2.0336088364213265045,2.6545247035270689295,0.67160716513933493843,-3.1828666758077464038,-0.35635939569553681805,-0.33893787265169356138,-3.0241455728900232813,1.62923025968103663,0.14749904795098447985,1.3144064013359400001,1.9046511649408164324,0.13075523505242278577,4.3909186600635399245,1.9474791474145720649,0.34986448736695469064,-3.9349793399422487994,-0.64947227496624837517,-1.9724256225350846883,0.61284660942039126397,-0.66138775495356272316,-2.6816093520633064173,1.6214899539771308046,-3.7559955941453302408,-3.9550864584222495957,-1.4666535406999394731,0.10995980227284518627,-3.4955477027595240891,-1.0646902469579164752 + ]) + + # Forward pass + Q = x1.shape[1] + xp1 = mapminmax_apply(x1, x1_step1) + a1 = tansig(np.outer(b1, np.ones(Q)) + IW1_1 @ xp1) + a2 = tansig(b2 + LW2_1 @ a1) + y1 = mapminmax_reverse(a2, y1_step1) + + # Denormalize output + minOutput = 2180.7944 + maxOutput = 26125.8109 + y1 = y1.T * (maxOutput - minOutput) + minOutput + + return y1 \ No newline at end of file From 1265c6bcc4342f5e7418cb90404f5597751ee9f2 Mon Sep 17 00:00:00 2001 From: bayc Date: Fri, 5 Dec 2025 11:29:02 -0700 Subject: [PATCH 02/11] integrating surrogate loads into FLORIS component --- ard/farm_aero/floris.py | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/ard/farm_aero/floris.py b/ard/farm_aero/floris.py index 97d12742..0564cc1a 100644 --- a/ard/farm_aero/floris.py +++ b/ard/farm_aero/floris.py @@ -7,6 +7,7 @@ import floris.turbine_library.turbine_utilities import ard.farm_aero.templates as templates +from ard.farm_loads.surrogate_load_functions import ANN_DEL_TowerBase def create_FLORIS_turbine_from_windIO( @@ -208,6 +209,9 @@ def setup(self): if hasattr(self.wind_query, "reference_height") else None ), + solver_settings=( + self.modeling_options.get("floris", {}).get("solver_settings") + ), ) self.case_title = self.options["case_title"] @@ -272,6 +276,40 @@ def get_thrust_turbines(self): else: return thrust_turbines.T + def get_tower_base_load(self): + SATI = self.fmodel.get_turbine_SATI() * 100 + SAWS = self.fmodel.get_turbine_SAWS() + turbine_powers_percent = self.fmodel.get_turbine_powers_percent().flatten() + + SATI_collapsed = SATI.reshape(-1, SATI.shape[-1]) + SAWS_collapsed = SAWS.reshape(-1, SAWS.shape[-1]) + + Yaw = self.fmodel.core.farm.yaw_angles.flatten() + + # [SAWSup SAWSright SAWSdown SAWSleft SATIup SATIright SATIdown SATIleft Yaw PowerDemand[%]] + input_data = np.concatenate( + ( + SAWS_collapsed, + SATI_collapsed, + Yaw[:, None], + turbine_powers_percent[:, None], + ), + axis=1, + ) + + # Make predictions using ANN surrogate + del_towerbase_ann = ANN_DEL_TowerBase(input_data) + + # Weight predictions by frequency of wind conditions + weighted_observed_pred = np.zeros_like (del_towerbase_ann) + + n_turbs = self.N_turbines + + for i, f in enumerate(self.wind_query.freq_table.flatten()): + weighted_observed_pred[i * n_turbs: i * n_turbs + n_turbs] = del_towerbase_ann[i * n_turbs: i * n_turbs + n_turbs] * f + + return np.sum(weighted_observed_pred) + def dump_floris_yamlfile(self, dir_output=None): """ Export the current FLORIS inputs to a YAML file file for reproducibility of the analysis. @@ -479,3 +517,34 @@ def compute(self, inputs, outputs): def setup_partials(self): FLORISFarmComponent.setup_partials(self) + + +class FLORISTowerBaseLoad(FLORISAEP): + """ + Component class for computing surrogate tower base loads using FLORIS. + """ + + def initialize(self): + super().initialize() # run super class script first! + + def setup(self): + super().setup() # run super class script first! + + self.add_output( + "tower_base_load", + 0.0, + units="kN*m", + desc="maximum tower base load across all wind conditions", + ) + + def setup_partials(self): + super().setup_partials() + + def compute(self, inputs, outputs): + super().compute(inputs, outputs) + outputs["tower_base_load"] = FLORISFarmComponent.get_tower_base_load(self, inputs) + outputs["AEP_farm"] = FLORISFarmComponent.get_AEP_farm(self) + + def setup_partials(self): + FLORISFarmComponent.setup_partials(self) + From bcd3a430ddf09a0fb239c43558417d8ef8e75003 Mon Sep 17 00:00:00 2001 From: bayc Date: Fri, 5 Dec 2025 11:32:03 -0700 Subject: [PATCH 03/11] adding surrogate load layout example --- .../inputs/ard_system.yaml | 152 ++++++++++++++++++ .../inputs/windio.yaml | 44 +++++ .../optimization_demo.py | 88 ++++++++++ .../x08_layout_with_surrogate_loads/plot.py | 134 +++++++++++++++ 4 files changed, 418 insertions(+) create mode 100644 examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml create mode 100644 examples/x08_layout_with_surrogate_loads/inputs/windio.yaml create mode 100644 examples/x08_layout_with_surrogate_loads/optimization_demo.py create mode 100644 examples/x08_layout_with_surrogate_loads/plot.py diff --git a/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml b/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml new file mode 100644 index 00000000..150e34eb --- /dev/null +++ b/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml @@ -0,0 +1,152 @@ +modeling_options: &modeling_options + windIO_plant: !include windio.yaml + layout: + # type: gridfarm + N_turbines: 9 + N_substations: 1 + aero: + return_turbine_output: True + collection: + max_turbines_per_string: 8 + solver_name: highs + solver_options: + time_limit: 60 + mip_gap: 0.02 + model_options: + topology: radial # radial, branched + feeder_route: segmented + feeder_limit: unlimited + offshore: false + floating: false + costs: + rated_power: 3400000.0 # W + num_blades: 3 + rated_thrust_N: 645645.83964671 + gust_velocity_m_per_s: 52.5 + blade_surface_area: 69.7974979 + tower_mass: 620.4407337521 + nacelle_mass: 101.98582836439 + hub_mass: 8.38407517646 + blade_mass: 14.56341339641 + foundation_height: 0.0 + commissioning_cost_kW: 44.0 + decommissioning_cost_kW: 58.0 + trench_len_to_substation_km: 50.0 + distance_to_interconnect_mi: 4.97096954 + interconnect_voltage_kV: 130.0 + tcc_per_kW: 1300.00 # (USD/kW) + opex_per_kW: 44.00 # (USD/kWh) + +system: + type: group + systems: + aepFLORIS: + type: component + module: ard.farm_aero.floris + object: FLORISTowerBaseLoad + promotes: ["x_turbines", "y_turbines", "AEP_farm", "tower_base_load"] + kwargs: + modeling_options: *modeling_options + data_path: + case_title: "default" + boundary: + type: component + module: ard.layout.boundary + object: FarmBoundaryDistancePolygon + promotes: ["*"] + kwargs: + modeling_options: *modeling_options + collection: + type: component + module: ard.collection.optiwindnet_wrap + object: OptiwindnetCollection + promotes: ["*"] + kwargs: + modeling_options: *modeling_options + spacing_constraint: + type: component + module: ard.layout.spacing + object: TurbineSpacing + promotes: ["*"] + kwargs: + modeling_options: *modeling_options + tcc: + type: component + module: ard.cost.wisdem_wrap + object: TurbineCapitalCosts + promotes: [ + "turbine_number", + "machine_rating", + "tcc_per_kW", + "offset_tcc_per_kW", + ] + landbosse: + type: component + module: ard.cost.wisdem_wrap + object: LandBOSSEWithSpacingApproximations + promotes: [ + "total_length_cables", + ] + kwargs: + modeling_options: *modeling_options + opex: + type: component + module: ard.cost.wisdem_wrap + object: OperatingExpenses + promotes: [ + "turbine_number", + "machine_rating", + "opex_per_kW" + ] + financese: + type: component + module: ard.cost.wisdem_wrap + object: FinanceSEGroup + promotes: [ + "turbine_number", + "machine_rating", + "tcc_per_kW", + "offset_tcc_per_kW", + "opex_per_kW", + ] + kwargs: + modeling_options: *modeling_options + connections: + - ["AEP_farm", "financese.plant_aep_in"] + - ["landbosse.total_capex_kW", "financese.bos_per_kW"] + +analysis_options: + driver: + name: ScipyOptimizeDriver + options: + optimizer: COBYLA + opt_settings: + rhobeg: 2.0 + maxiter: 150 + debug_print: + - desvars + - objs + design_variables: + x_turbines: + units: km + lower: -3.0 + upper: 3.0 + scaler: 1.0e1 + y_turbines: + units: km + lower: -3.0 + upper: 3.0 + scaler: 1.0e1 + constraints: + boundary_distances: + units: km + upper: 0.0 + scaler: 2.0 + spacing_constraint.turbine_spacing: + units: km + lower: 0.552 + objectives: + aepFLORIS.tower_base_load: + scaler: 1.0 + recorder: + filepath: cases.sql diff --git a/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml b/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml new file mode 100644 index 00000000..8b8f6cb0 --- /dev/null +++ b/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml @@ -0,0 +1,44 @@ +name: Ard Example 01 onshore wind plant +site: + name: Ard Example 01 offshore wind site + boundaries: + polygons: + - x: [ 1500.0, 3000.0, 3000.0, 1500.0, -1500.0, -3000.0, -3000.0, -1500.0] + y: [ 3000.0, 1500.0, -1500.0, -3000.0, -3000.0, -1500.0, 1500.0, 3000.0] + energy_resource: + name: Ard Example 01 offshore energy resource + wind_resource: !include ../../data/windIO-plant_wind-resource_wrg-example_copy.yaml +wind_farm: + name: Ard Example 01 offshore wind farm + layouts: + coordinates: + # x: [ + # -2500.0, -1250.0, 0.0, 1250.0, 2500.0, + # -2500.0, -1250.0, 0.0, 1250.0, 2500.0, + # -2500.0, -1250.0, 0.0, 1250.0, 2500.0, + # -2500.0, -1250.0, 0.0, 1250.0, 2500.0, + # -2500.0, -1250.0, 0.0, 1250.0, 2500.0 + # ] + # y: [ + # -2500.0, -2500.0, -2500.0, -2500.0, -2500.0, + # -1250.0, -1250.0, -1250.0, -1250.0, -1250.0, + # 0.0, 0.0, 0.0, 0.0, 0.0, + # 1250.0, 1250.0, 1250.0, 1250.0, 1250.0, + # 2500.0, 2500.0, 2500.0, 2500.0, 2500.0 + # ] + x: [ + -1250.0, 0.0, 1250.0, + -1250.0, 0.0, 1250.0, + -1250.0, 0.0, 1250.0, + ] + y: [ + -1250.0, -1250.0, -1250.0, + 0.0, 0.0, 0.0, + 1250.0, 1250.0, 1250.0, + ] + turbine: !include ../../data/windIO-plant_turbine_IEA-3.4MW-130m-RWT.yaml + electrical_substations: + - electrical_substation: + coordinates: + x: [100.0] + y: [100.0] \ No newline at end of file diff --git a/examples/x08_layout_with_surrogate_loads/optimization_demo.py b/examples/x08_layout_with_surrogate_loads/optimization_demo.py new file mode 100644 index 00000000..994fb9b4 --- /dev/null +++ b/examples/x08_layout_with_surrogate_loads/optimization_demo.py @@ -0,0 +1,88 @@ +from pathlib import Path # optional, for nice path specifications + +import pprint as pp # optional, for nice printing +import numpy as np # numerics library +import matplotlib.pyplot as plt # plotting capabilities + +import ard # technically we only really need this +from ard.utils.io import load_yaml # we grab a yaml loader here +from ard.api import set_up_ard_model # the secret sauce +from ard.viz.layout import plot_layout # a plotting tool! + +import openmdao.api as om # for N2 diagrams from the OpenMDAO backend + +# %matplotlib inline + +# load input +path_inputs = Path.cwd().absolute() / "inputs" +input_dict = load_yaml(path_inputs / "ard_system.yaml") + +# create and setup system + +prob = set_up_ard_model(input_dict=input_dict, root_data_path=path_inputs) +prob.model.set_input_defaults('x_turbines', val=input_dict["modeling_options"]["windIO_plant"]["wind_farm"]["layouts"]["coordinates"]["x"]) +prob.model.set_input_defaults('y_turbines', val=input_dict["modeling_options"]["windIO_plant"]["wind_farm"]["layouts"]["coordinates"]["y"]) + +if False: + # visualize model + om.n2(prob) + +# run the model +prob.run_model() + +# collapse the test result data +test_data = { + "AEP_val": float(prob.get_val("AEP_farm", units="GW*h")[0]), + "CapEx_val": float(prob.get_val("tcc.tcc", units="MUSD")[0]), + "BOS_val": float(prob.get_val("landbosse.total_capex", units="MUSD")[0]), + "OpEx_val": float(prob.get_val("opex.opex", units="MUSD/yr")[0]), + "LCOE_val": float(prob.get_val("financese.lcoe", units="USD/MW/h")[0]), + "coll_length": float(prob.get_val("collection.total_length_cables", units="km")[0]), + "turbine_spacing": float( + np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) + ), + "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), +} + +print("\n\nRESULTS:\n") +pp.pprint(test_data) +print("\n\n") + +optimize = True # set to False to skip optimization +if optimize: + # run the optimization + prob.run_driver() + prob.cleanup() + + # collapse the test result data + test_data = { + "AEP_val": float(prob.get_val("AEP_farm", units="GW*h")[0]), + "CapEx_val": float(prob.get_val("tcc.tcc", units="MUSD")[0]), + "BOS_val": float(prob.get_val("landbosse.total_capex", units="MUSD")[0]), + "OpEx_val": float(prob.get_val("opex.opex", units="MUSD/yr")[0]), + "LCOE_val": float(prob.get_val("financese.lcoe", units="USD/MW/h")[0]), + "coll_length": float( + prob.get_val("collection.total_length_cables", units="km")[0] + ), + "turbine_spacing": float( + np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) + ), + "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), + } + + # clean up the recorder + prob.cleanup() + + # print the results + print("\n\nRESULTS (opt):\n") + pp.pprint(test_data) + print("\n\n") + +plot_layout( + prob, + input_dict=input_dict, + show_image=True, + include_cable_routing=True, +) +plt.show() + diff --git a/examples/x08_layout_with_surrogate_loads/plot.py b/examples/x08_layout_with_surrogate_loads/plot.py new file mode 100644 index 00000000..986a4b0a --- /dev/null +++ b/examples/x08_layout_with_surrogate_loads/plot.py @@ -0,0 +1,134 @@ +import matplotlib.pyplot as plt +import openmdao.api as om +import numpy as np +import dill as pickle +import optiwindnet.plotting + +plt.rcParams['font.size'] = 20 + +# Instantiate your CaseReader +# cr = om.CaseReader("optimization_demo_out/gridfarm_9turbs_50iters_COBYLA/opt_results.sql") +case_dir = "ard_prob_out/test_out/cases.sql" +# case_dir = "optimization_demo_out/gridfarm_9turbs_7500maxcablelength_200iters_COBYLA_max_AEP" +cr = om.CaseReader(case_dir + "/opt_results.sql") + +# Get driver cases (do not recurse to system/solver cases) +driver_cases = cr.get_cases('driver', recurse=False) + +# Get a list of cases for the objective component +layout2aep_cases = cr.list_cases('root.layout2aep', out_stream=None) + +# layout = cr.list_cases('root.layout', out_stream=None) + +optiwindnet_coll = cr.list_cases('root.optiwindnet_coll', out_stream=None) + +# Plot the path the design variables took to convergence +# Note that there are two lines in the right plot because "Z" +# contains two variables that are being optimized +# dv_x_values = [] +# dv_z_values = [] +# for case in driver_cases: +# dv_x_values.append(case['tower_base_load']) + # dv_x_values.append(case['AEP_farm']) + # dv_z_values.append(case['AEP_farm']) + +objectives = [] +AEPs = [] +for case in driver_cases: + objectives.append(case.outputs['tower_base_load']) + # objectives.append(case.outputs['AEP_farm']) + +AEPs = [] +tower_loads = [] +spacing_effective_primary = [] +spacing_effective_secondary = [] +for case_id in layout2aep_cases: + case = cr.get_case(case_id) + AEPs.append(case['AEP_farm']) + tower_loads.append(case['tower_base_load']) + spacing_effective_primary.append(case['spacing_effective_primary']) + spacing_effective_secondary.append(case['spacing_effective_secondary']) + +# print(AEPs[-1]) +# print(objectives[-1]) +# lkj + +# x_locations = [] +# y_locations = [] +# for case_id in layout: +# case = cr.get_case(case_id) +# x_locations.append(case['x_locations']) +# y_locations.append(case['y_locations']) + +tot_length_cables = [] +for case_id in optiwindnet_coll: + case = cr.get_case(case_id) + tot_length_cables.append(case['optiwindnet_coll.total_length_cables']) + +# for i, graph in enumerate(graphs): +# optiwindnet.plotting.gplot(graph) +# plt.savefig('optimization_demo_out/plots/iter_' + str(i) + '.png') + +n_iters = 50 + +# for i in range(n_iters): +for i in [50]: + + fig, axes= plt.subplots(2, 3, figsize=(21, 12)) + fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.5, hspace=None) + + axes[0,0].plot(np.arange(len(objectives[0:i])), np.array(objectives[0:i])) + axes[0,0].set(xlabel='Iterations', ylabel='Weighted Sum Tower Base DEL', title='Optimization History') + axes[0,0].grid() + + axes[0,1].plot(np.arange(len(AEPs[0:i])), np.array(AEPs[0:i]) / 1E9) + axes[0,1].set(xlabel='Iterations', ylabel='AEP [GWh]', title='Optimization History') + axes[0,1].grid() + + # axes[0,0].plot(np.arange(len(tower_loads[0:i])), np.array(tower_loads[0:i])) + # axes[0,0].set(xlabel='Iterations', ylabel='Weighted Sum Tower Base Load', title='Optimization History') + # axes[0,0].grid() + + # axes[0,1].plot(np.arange(len(objectives[0:i])), -1 * np.array(objectives[0:i]) / 1E9) + # axes[0,1].set(xlabel='Iterations', ylabel='AEP [GWh]', title='Optimization History') + # axes[0,1].grid() + + axes[0,2].plot(np.arange(len(tot_length_cables[0:i])), np.array(tot_length_cables[0:i])) + axes[0,2].set(xlabel='Iterations', ylabel='Total Cable Length [m]', title='Optimization History') + axes[0,2].grid() + + axes[1,0].plot( + np.arange(len(spacing_effective_primary[0:i])), + np.array(spacing_effective_primary[0:i]) + ) + axes[1,0].set(xlabel='Iterations', ylabel='Primary Spacing [D]', title='Optimization History') + axes[1,0].grid() + + axes[1,1].plot( + np.arange(len(spacing_effective_secondary[0:i])), + np.array(spacing_effective_secondary[0:i]) + ) + axes[1,1].set(xlabel='Iterations', ylabel='Secondary Spacing [D]', title='Optimization History') + axes[1,1].grid() + + file_name = case_dir + '/plots/iter_' + str(i) + '_graph.p' + with open(file_name, "rb") as file: + graph = pickle.load(file) + optiwindnet.plotting.gplot(graph, ax=axes[1,2]) + + fig.tight_layout() + plt.savefig(case_dir + '/plots/iter_' + str(i) + '_plot.png') + plt.close() + +# fig, (ax1, ax2) = plt.subplots(1, 2) +# fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.5, hspace=None) + +# ax1.plot(np.arange(len(dv_x_values)), np.array(dv_x_values)) +# ax1.set(xlabel='Iterations', ylabel='Design Var: X', title='Optimization History') +# ax1.grid() + +# ax2.plot(np.arange(len(dv_z_values)), np.array(dv_z_values)) +# ax2.set(xlabel='Iterations', ylabel='Design Var: Z', title='Optimization History') +# ax2.grid() + +# plt.show() \ No newline at end of file From c05d052e022b0980f812b5a766ee11ea4de2cc52 Mon Sep 17 00:00:00 2001 From: Cory Frontin Date: Fri, 5 Dec 2025 11:55:59 -0700 Subject: [PATCH 04/11] small touch-ups for missed changes --- ard/farm_aero/floris.py | 2 +- examples/x08_layout_with_surrogate_loads/inputs/windio.yaml | 2 +- pyproject.toml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ard/farm_aero/floris.py b/ard/farm_aero/floris.py index 0564cc1a..7e480485 100644 --- a/ard/farm_aero/floris.py +++ b/ard/farm_aero/floris.py @@ -542,7 +542,7 @@ def setup_partials(self): def compute(self, inputs, outputs): super().compute(inputs, outputs) - outputs["tower_base_load"] = FLORISFarmComponent.get_tower_base_load(self, inputs) + outputs["tower_base_load"] = FLORISFarmComponent.get_tower_base_load(self) outputs["AEP_farm"] = FLORISFarmComponent.get_AEP_farm(self) def setup_partials(self): diff --git a/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml b/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml index 8b8f6cb0..c287c964 100644 --- a/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml +++ b/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml @@ -7,7 +7,7 @@ site: y: [ 3000.0, 1500.0, -1500.0, -3000.0, -3000.0, -1500.0, 1500.0, 3000.0] energy_resource: name: Ard Example 01 offshore energy resource - wind_resource: !include ../../data/windIO-plant_wind-resource_wrg-example_copy.yaml + wind_resource: !include ../../data/windIO-plant_wind-resource_wrg-example.yaml wind_farm: name: Ard Example 01 offshore wind farm layouts: diff --git a/pyproject.toml b/pyproject.toml index 8ceeacfc..4cce0029 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,8 @@ classifiers = [ ] dependencies = [ "numpy<2.3", - "floris>=4.3", + # "floris>=4.3", + "floris @ git+https://github.com/bayc/floris.git@feature/surrogate_loads", "wisdem>=3.21", "NLopt", "marmot-agents", From 4e58c6be743c96e94f8c33c3237be6a8aad146af Mon Sep 17 00:00:00 2001 From: bayc Date: Tue, 9 Dec 2025 15:46:25 -0700 Subject: [PATCH 05/11] add blade root del function --- ard/farm_loads/surrogate_load_functions.py | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/ard/farm_loads/surrogate_load_functions.py b/ard/farm_loads/surrogate_load_functions.py index 2b81ad3c..28c5d468 100644 --- a/ard/farm_loads/surrogate_load_functions.py +++ b/ard/farm_loads/surrogate_load_functions.py @@ -62,4 +62,59 @@ def ANN_DEL_TowerBase(x1): maxOutput = 26125.8109 y1 = y1.T * (maxOutput - minOutput) + minOutput + return y1 + +def ANN_DEL_BladeRoot(x1): + x1 = np.array(x1, dtype=np.float64) + if x1.ndim == 1: + x1 = x1.reshape(1, -1) + if x1.shape[1] != 10: + raise ValueError("Input must have shape (Q, 10)") + + # Normalize input + minInputs = np.array([3.36093, 3.43696, 3.36454, 3.41895, 8.07273, 8.23081, 8.67988, 8.44285, -30, 60]) + maxInputs = np.array([14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100]) + x1 = (x1 - minInputs) / (maxInputs - minInputs) + x1 = x1.T # (10, Q) + + # Preprocessing settings + x1_step1 = { + 'xoffset': np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), + 'gain': np.array([2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2]), + 'ymin': -1 + } + + y1_step1 = { + 'ymin': -1, + 'gain': 2.06245121975435, + 'xoffset': 0 + } + + # Neural net weights (Layer 1 and 2) + b1 = np.array([ + 0.54366944462409116934,0.31294379591009785502,-0.51189926508535932292,1.4881933190659204502,-0.6288956595742227762,-0.19359627640225313128,0.39137621590253535153,-1.0366649402122289914,0.55534527483506990198,0.18839221921288695771,-0.078706228422190604999,0.046792462423330301313,0.69232199957340845309,-0.74109280839050772904,-5.4456938554121316898,-0.080904369300827672085,-1.4551520598122729133,0.80313766438230504985,-0.13330255544478317176,-1.941023842180298109,1.6791433222290104155,1.2403777148882095815,-1.8054044309269281499,-0.10233143369148571533,0.79884202496933298665,-0.87816344068184881699,-0.72496721667128649624,-0.58219149095682520834,1.0472757666203991178,-0.3205217551283675026 + ]) + + b2 = -0.11631999509276053084 + + IW1_1 = np.array([ + [-0.9691541463169519588,-2.2082729161680534347,0.16322708809662275775,-0.030756863950325008528,-1.0668806280715801282,-0.28313582544797699647,1.4448560046137648438,0.032219573319804545308,0.25171283771525176931,-0.17830776446566862226],[-0.27228457256496318983,0.3785601780705833419,0.98266246214658969915,-1.3002810761955083674,-0.59192836496933864954,0.41117076156796644737,0.65150623661735718173,0.051330444549634708651,-0.46355296447057908749,-0.091790529001709156298],[1.086423022676347161,-0.55056610766413871527,0.027502769669224082227,1.1970701351400578893,1.293204485031062223,0.68504100358047015362,-2.6307913270293430408,0.95175716385282904675,-0.003006693817982381868,-0.18289221463576066373],[-0.27086973358198429551,1.9668420111618776236,2.073344235104797928,-0.37815115748314009902,0.031034569853559543923,0.39294666816021722733,1.4711446564972989748,-0.39087973432280370689,-0.051711373032646938686,-1.0508683142907673247],[-2.3707952492667327959,0.80069620830602927786,-1.1985705973028708549,-1.1271594560347750758,1.5479906631647339932,-0.76302763776628734771,0.11964566328780874838,-1.8307784479098603292,-0.06575321004638125244,-0.74589535016533248246],[0.22861523374558745392,-0.30551666836510621428,0.70528007692483773994,-0.21897051394009994785,0.38667705598732321493,0.32851840824230033045,0.18288952564016172642,-0.63396686470231611299,-0.51754919082022632359,-0.0034820766021412740895],[2.3561424580978442833,2.2681032820259843241,2.113918665617255499,-1.881036922676615708,-0.92943715409177052322,1.1749568861944190701,1.5570938607363293826,-0.33711975479166728098,0.11168831102751085316,-0.67485343036208744749],[-0.73364544036874212996,-0.87531583385826428056,1.2211284010742822215,0.67079957890499741779,0.068091287898962432612,-1.0348196946651282424,2.3906469772779046501,-1.747756061063288513,0.56268533373028373212,0.07973393811332304959],[0.21913089304261071377,1.0048470828366196095,-0.56728089234775902483,-1.2814967610504304218,-0.070467424528017588714,0.59743437336564553242,-1.1991834521803419467,0.84785982778085089429,-0.38418954858234133365,-0.063367996792277503371],[0.38238257660750030187,-1.5986421851254277726,-0.10573333916376159713,1.9496279169919061847,1.2867139392249535845,-0.17606069678139857348,-1.1507047525974840596,-0.18901790190493572563,0.66251721190207302215,0.085336100111380361333],[0.331800481834342742,-1.5085073941879851844,0.54449662178545166213,0.16440346954165099835,2.2587535147550066306,0.072497765193573898701,-1.4029161615611951408,-1.1273219005764036904,0.58577657017349327173,-0.21708439640900550893],[0.0090942014805446037828,2.0058526610487663611,-0.73664883685957416315,-1.9278553412925791832,-0.35464938529176925908,-0.10934821545468835502,0.23633872117319129624,0.21834430340219959654,-0.49006514257276378999,-0.081089762175526824972],[-1.1411976086703647937,-0.36481663214936238537,-0.39850948254482049249,-0.024895681856923042308,-1.1852946404874558084,0.35351002979606166443,0.79721041126107095032,-0.073634700495875060611,0.052426433188170390443,0.42058794228898904732],[0.47190044417647131203,-0.037889773969072837456,-1.2621561451633631634,0.68778546361877335169,0.18825936446146562808,1.0521269388873222272,-1.0867390289565972417,0.8183274318725353158,-0.033876635499573190535,-0.09502388360096158948],[0.55669774669443139459,3.0027684104964214029,0.40045869604030209787,0.92883946502768355291,4.1183864722698872995,-2.88294730843829905,2.3024854611343856803,3.0798604018907638213,0.35982651618929395454,0.4749359085730352481],[-0.93237508055082340963,-0.27291225495976745297,0.049393090857986578224,0.71248685845573545006,1.7923704541165901283,0.062034506301660234662,-1.0637860947322796967,-0.87927695587562360036,0.38576024582891432768,-0.22142151912150490056],[-1.2691077476496521736,-1.1867402146653003303,-2.1384502481696103793,1.065859627353023642,-0.48167446540824260248,0.066635866402156768151,-0.84750389620879051922,0.7055359190516925505,-0.22962234434907838332,0.59934675700423178935],[1.1459093098487915796,-0.58235794152739916996,3.1218756058823795563,-3.2532509447226272137,0.85125518731919758153,-2.125512469517314873,1.9789020460960036196,-1.9076761191135580553,-0.29694594227099480044,0.055091980110211519195],[0.088701574927947474114,-3.3998635154646130729,1.3233098139056098663,0.99068016840129979883,-1.2803161599652479463,-0.77116696798005579527,-2.3165734929254004903,0.66143191753427910129,0.013309392181332257987,1.0974885416793895843],[0.26991105171154072817,0.79089103942962690752,1.7406563340294087805,0.511381468956811025,-1.5137513068586612164,-1.1677363904868975908,1.9794293598478509555,0.46572973206621398612,-0.089833829810027091001,0.14819660128737038862],[0.99824650207053766682,1.0360546329400945886,-1.5895856530540735108,1.7245383977007640031,0.52572322657377812405,0.67910458688279262685,-1.182023049853849761,0.09104333676800291375,0.35469003514738067784,-0.12181382852712477338],[0.56214019008643079101,1.0745508138310606583,0.61312938827733465263,2.447985751329599502,-2.1998320803880888619,1.8748360217216732959,-0.66166231032422107017,2.4004555112192353938,0.026167820791865192831,0.5840463875785829595],[0.56465359716006746638,-0.9764957902556280489,-2.6241885196099414834,-0.77645480301266278644,0.64044861483177883965,0.021451528077588592758,-2.4581396730358702207,0.31020872458758308454,0.10863088515303774562,0.6486685177642154132],[2.3755911413073231842,-0.92494159162788791573,-0.16334825155607449187,-1.9312970205272603774,1.2127333286470038942,-1.5719539210160768938,0.53939222729209046481,-1.3703694200819782623,-0.30199023525727608508,0.032666268661235745019],[-0.99109827312085829742,-1.378883390133445408,-0.25527439695746484416,0.27070735177912941261,-0.10671853591879483514,0.073505947527277515352,0.10524465629064236327,0.098978621772914290866,0.1428638679352601526,-0.007912130839509800076],[-0.755120465258354856,-1.7238989284471688546,-1.6538923820335600379,2.0471245945044915793,-0.57351368935018787187,-1.222406031088757894,-1.2961379775532957392,0.66485717209253503146,0.027370067050677331782,0.21054603968499563393],[2.0343535816248237147,0.33562953740282586157,-0.42825323868011294648,-2.5072524404011975463,-0.26919547296005669201,0.62752492885057076233,-0.16158182046139132892,-0.22367853646109667198,-0.82518406351324891101,0.11336141663162481452],[0.51730138436926242917,0.11304189712785341071,-0.047412083258119581963,0.45660927170827048105,-0.26896010527340541429,1.3026924350269559749,-0.60371505631623190169,1.2596691186684922936,-0.41809873387871737682,-0.072923818026420367255],[0.58635947171035984748,-0.15879822271506360831,-0.040694077286644106395,-0.97548803872086797817,1.2009690009127382826,1.0869989849449628316,-0.3185783820724945592,-1.8137429492431995648,-0.8722777573222401104,-0.16520814459267130214],[-0.70266414052749803787,0.9574121285645278423,-0.94729927589585849468,-0.28224981146191646664,-0.14398138695462697756,-0.61162380331148646917,0.32601346272075665267,-0.11794700810447451833,0.2033944761077132457,-0.12300534273502794491] + ]) + + LW2_1 = np.array([ + 1.5598411501307831717,3.0518213473977828798,1.9692286411650965494,0.68408854039050825957,1.1269238219932133926,-2.6312197636288825464,-0.74334398169426096903,-1.6728462595975237548,-4.5277731890756109934,2.0394142452183401382,-1.4677828109204844598,2.8071790565928202987,2.6558903870346637355,-4.1710887662639057893,2.8206050038847387817,2.1170071154749972031,0.54806101255802652794,-1.5114297743564342191,0.11532237677727565084,-1.9704061919624336063,0.81301711728032177717,0.9545086499966127791,0.45826792051469911193,1.2195869429760046732,-4.2594350561452678505,-0.64174811370623130458,0.86184766619713892855,1.6746818427659309059,-0.62475945690155054724,-1.8575118942617874218 + ]) + + # Forward pass + Q = x1.shape[1] + xp1 = mapminmax_apply(x1, x1_step1) + a1 = tansig(np.outer(b1, np.ones(Q)) + IW1_1 @ xp1) + a2 = tansig(b2 + LW2_1 @ a1) + y1 = mapminmax_reverse(a2, y1_step1) + + # Denormalize output + minOutput = 2032.1701 + maxOutput = 3961.0986 + y1 = y1.T * (maxOutput - minOutput) + minOutput + return y1 \ No newline at end of file From fa8fe0289eb29934e9812a27c6e7961e68b2d9c0 Mon Sep 17 00:00:00 2001 From: Christopher Bay Date: Fri, 12 Dec 2025 11:45:11 -0700 Subject: [PATCH 06/11] adding other surrogate load functions --- ard/farm_loads/surrogate_load_functions.py | 1981 +++++++++++++++++++- 1 file changed, 1930 insertions(+), 51 deletions(-) diff --git a/ard/farm_loads/surrogate_load_functions.py b/ard/farm_loads/surrogate_load_functions.py index 28c5d468..b9e1cbde 100644 --- a/ard/farm_loads/surrogate_load_functions.py +++ b/ard/farm_loads/surrogate_load_functions.py @@ -1,13 +1,1011 @@ import numpy as np + def tansig(x): return 2 / (1 + np.exp(-2 * x)) - 1 + def mapminmax_apply(x, settings): - return (x - settings['xoffset'][:, np.newaxis]) * settings['gain'][:, np.newaxis] + settings['ymin'] + return (x - settings["xoffset"][:, np.newaxis]) * settings["gain"][ + :, np.newaxis + ] + settings["ymin"] + def mapminmax_reverse(y, settings): - return (y - settings['ymin']) / settings['gain'] + settings['xoffset'] + return (y - settings["ymin"]) / settings["gain"] + settings["xoffset"] + + +def ANN_DEL_BladeRoot(x1): + x1 = np.array(x1, dtype=np.float64) + if x1.ndim == 1: + x1 = x1.reshape(1, -1) + if x1.shape[1] != 10: + raise ValueError("Input must have shape (Q, 10)") + + # Normalize input + minInputs = np.array( + [ + 3.36093, + 3.43696, + 3.36454, + 3.41895, + 8.07273, + 8.23081, + 8.67988, + 8.44285, + -30, + 60, + ] + ) + maxInputs = np.array( + [14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100] + ) + x1 = (x1 - minInputs) / (maxInputs - minInputs) + x1 = x1.T # (10, Q) + + # Preprocessing settings + x1_step1 = { + "xoffset": np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), + "gain": np.array( + [2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2] + ), + "ymin": -1, + } + + y1_step1 = { + "ymin": -1, + "gain": 2.06245121975435, + "xoffset": 0, + } + + # Neural net weights (Layer 1 and 2) + b1 = np.array( + [ + 0.54366944462409116934, + 0.31294379591009785502, + -0.51189926508535932292, + 1.4881933190659204502, + -0.6288956595742227762, + -0.19359627640225313128, + 0.39137621590253535153, + -1.0366649402122289914, + 0.55534527483506990198, + 0.18839221921288695771, + -0.078706228422190604999, + 0.046792462423330301313, + 0.69232199957340845309, + -0.74109280839050772904, + -5.4456938554121316898, + -0.080904369300827672085, + -1.4551520598122729133, + 0.80313766438230504985, + -0.13330255544478317176, + -1.941023842180298109, + 1.6791433222290104155, + 1.2403777148882095815, + -1.8054044309269281499, + -0.10233143369148571533, + 0.79884202496933298665, + -0.87816344068184881699, + -0.72496721667128649624, + -0.58219149095682520834, + 1.0472757666203991178, + -0.3205217551283675026, + ] + ) + + b2 = -0.11631999509276053084 + + IW1_1 = np.array( + [ + [ + -0.9691541463169519588, + -2.2082729161680534347, + 0.16322708809662275775, + -0.030756863950325008528, + -1.0668806280715801282, + -0.28313582544797699647, + 1.4448560046137648438, + 0.032219573319804545308, + 0.25171283771525176931, + -0.17830776446566862226, + ], + [ + -0.27228457256496318983, + 0.3785601780705833419, + 0.98266246214658969915, + -1.3002810761955083674, + -0.59192836496933864954, + 0.41117076156796644737, + 0.65150623661735718173, + 0.051330444549634708651, + -0.46355296447057908749, + -0.091790529001709156298, + ], + [ + 1.086423022676347161, + -0.55056610766413871527, + 0.027502769669224082227, + 1.1970701351400578893, + 1.293204485031062223, + 0.68504100358047015362, + -2.6307913270293430408, + 0.95175716385282904675, + -0.003006693817982381868, + -0.18289221463576066373, + ], + [ + -0.27086973358198429551, + 1.9668420111618776236, + 2.073344235104797928, + -0.37815115748314009902, + 0.031034569853559543923, + 0.39294666816021722733, + 1.4711446564972989748, + -0.39087973432280370689, + -0.051711373032646938686, + -1.0508683142907673247, + ], + [ + -2.3707952492667327959, + 0.80069620830602927786, + -1.1985705973028708549, + -1.1271594560347750758, + 1.5479906631647339932, + -0.76302763776628734771, + 0.11964566328780874838, + -1.8307784479098603292, + -0.06575321004638125244, + -0.74589535016533248246, + ], + [ + 0.22861523374558745392, + -0.30551666836510621428, + 0.70528007692483773994, + -0.21897051394009994785, + 0.38667705598732321493, + 0.32851840824230033045, + 0.18288952564016172642, + -0.63396686470231611299, + -0.51754919082022632359, + -0.0034820766021412740895, + ], + [ + 2.3561424580978442833, + 2.2681032820259843241, + 2.113918665617255499, + -1.881036922676615708, + -0.92943715409177052322, + 1.1749568861944190701, + 1.5570938607363293826, + -0.33711975479166728098, + 0.11168831102751085316, + -0.67485343036208744749, + ], + [ + -0.73364544036874212996, + -0.87531583385826428056, + 1.2211284010742822215, + 0.67079957890499741779, + 0.068091287898962432612, + -1.0348196946651282424, + 2.3906469772779046501, + -1.747756061063288513, + 0.56268533373028373212, + 0.07973393811332304959, + ], + [ + 0.21913089304261071377, + 1.0048470828366196095, + -0.56728089234775902483, + -1.2814967610504304218, + -0.070467424528017588714, + 0.59743437336564553242, + -1.1991834521803419467, + 0.84785982778085089429, + -0.38418954858234133365, + -0.063367996792277503371, + ], + [ + 0.38238257660750030187, + -1.5986421851254277726, + -0.10573333916376159713, + 1.9496279169919061847, + 1.2867139392249535845, + -0.17606069678139857348, + -1.1507047525974840596, + -0.18901790190493572563, + 0.66251721190207302215, + 0.085336100111380361333, + ], + [ + 0.331800481834342742, + -1.5085073941879851844, + 0.54449662178545166213, + 0.16440346954165099835, + 2.2587535147550066306, + 0.072497765193573898701, + -1.4029161615611951408, + -1.1273219005764036904, + 0.58577657017349327173, + -0.21708439640900550893, + ], + [ + 0.0090942014805446037828, + 2.0058526610487663611, + -0.73664883685957416315, + -1.9278553412925791832, + -0.35464938529176925908, + -0.10934821545468835502, + 0.23633872117319129624, + 0.21834430340219959654, + -0.49006514257276378999, + -0.081089762175526824972, + ], + [ + -1.1411976086703647937, + -0.36481663214936238537, + -0.39850948254482049249, + -0.024895681856923042308, + -1.1852946404874558084, + 0.35351002979606166443, + 0.79721041126107095032, + -0.073634700495875060611, + 0.052426433188170390443, + 0.42058794228898904732, + ], + [ + 0.47190044417647131203, + -0.037889773969072837456, + -1.2621561451633631634, + 0.68778546361877335169, + 0.18825936446146562808, + 1.0521269388873222272, + -1.0867390289565972417, + 0.8183274318725353158, + -0.033876635499573190535, + -0.09502388360096158948, + ], + [ + 0.55669774669443139459, + 3.0027684104964214029, + 0.40045869604030209787, + 0.92883946502768355291, + 4.1183864722698872995, + -2.88294730843829905, + 2.3024854611343856803, + 3.0798604018907638213, + 0.35982651618929395454, + 0.4749359085730352481, + ], + [ + -0.93237508055082340963, + -0.27291225495976745297, + 0.049393090857986578224, + 0.71248685845573545006, + 1.7923704541165901283, + 0.062034506301660234662, + -1.0637860947322796967, + -0.87927695587562360036, + 0.38576024582891432768, + -0.22142151912150490056, + ], + [ + -1.2691077476496521736, + -1.1867402146653003303, + -2.1384502481696103793, + 1.065859627353023642, + -0.48167446540824260248, + 0.066635866402156768151, + -0.84750389620879051922, + 0.7055359190516925505, + -0.22962234434907838332, + 0.59934675700423178935, + ], + [ + 1.1459093098487915796, + -0.58235794152739916996, + 3.1218756058823795563, + -3.2532509447226272137, + 0.85125518731919758153, + -2.125512469517314873, + 1.9789020460960036196, + -1.9076761191135580553, + -0.29694594227099480044, + 0.055091980110211519195, + ], + [ + 0.088701574927947474114, + -3.3998635154646130729, + 1.3233098139056098663, + 0.99068016840129979883, + -1.2803161599652479463, + -0.77116696798005579527, + -2.3165734929254004903, + 0.66143191753427910129, + 0.013309392181332257987, + 1.0974885416793895843, + ], + [ + 0.26991105171154072817, + 0.79089103942962690752, + 1.7406563340294087805, + 0.511381468956811025, + -1.5137513068586612164, + -1.1677363904868975908, + 1.9794293598478509555, + 0.46572973206621398612, + -0.089833829810027091001, + 0.14819660128737038862, + ], + [ + 0.99824650207053766682, + 1.0360546329400945886, + -1.5895856530540735108, + 1.7245383977007640031, + 0.52572322657377812405, + 0.67910458688279262685, + -1.182023049853849761, + 0.09104333676800291375, + 0.35469003514738067784, + -0.12181382852712477338, + ], + [ + 0.56214019008643079101, + 1.0745508138310606583, + 0.61312938827733465263, + 2.447985751329599502, + -2.1998320803880888619, + 1.8748360217216732959, + -0.66166231032422107017, + 2.4004555112192353938, + 0.026167820791865192831, + 0.5840463875785829595, + ], + [ + 0.56465359716006746638, + -0.9764957902556280489, + -2.6241885196099414834, + -0.77645480301266278644, + 0.64044861483177883965, + 0.021451528077588592758, + -2.4581396730358702207, + 0.31020872458758308454, + 0.10863088515303774562, + 0.6486685177642154132, + ], + [ + 2.3755911413073231842, + -0.92494159162788791573, + -0.16334825155607449187, + -1.9312970205272603774, + 1.2127333286470038942, + -1.5719539210160768938, + 0.53939222729209046481, + -1.3703694200819782623, + -0.30199023525727608508, + 0.032666268661235745019, + ], + [ + -0.99109827312085829742, + -1.378883390133445408, + -0.25527439695746484416, + 0.27070735177912941261, + -0.10671853591879483514, + 0.073505947527277515352, + 0.10524465629064236327, + 0.098978621772914290866, + 0.1428638679352601526, + -0.007912130839509800076, + ], + [ + -0.755120465258354856, + -1.7238989284471688546, + -1.6538923820335600379, + 2.0471245945044915793, + -0.57351368935018787187, + -1.222406031088757894, + -1.2961379775532957392, + 0.66485717209253503146, + 0.027370067050677331782, + 0.21054603968499563393, + ], + [ + 2.0343535816248237147, + 0.33562953740282586157, + -0.42825323868011294648, + -2.5072524404011975463, + -0.26919547296005669201, + 0.62752492885057076233, + -0.16158182046139132892, + -0.22367853646109667198, + -0.82518406351324891101, + 0.11336141663162481452, + ], + [ + 0.51730138436926242917, + 0.11304189712785341071, + -0.047412083258119581963, + 0.45660927170827048105, + -0.26896010527340541429, + 1.3026924350269559749, + -0.60371505631623190169, + 1.2596691186684922936, + -0.41809873387871737682, + -0.072923818026420367255, + ], + [ + 0.58635947171035984748, + -0.15879822271506360831, + -0.040694077286644106395, + -0.97548803872086797817, + 1.2009690009127382826, + 1.0869989849449628316, + -0.3185783820724945592, + -1.8137429492431995648, + -0.8722777573222401104, + -0.16520814459267130214, + ], + [ + -0.70266414052749803787, + 0.9574121285645278423, + -0.94729927589585849468, + -0.28224981146191646664, + -0.14398138695462697756, + -0.61162380331148646917, + 0.32601346272075665267, + -0.11794700810447451833, + 0.2033944761077132457, + -0.12300534273502794491, + ], + ] + ) + + LW2_1 = np.array( + [ + 1.5598411501307831717, + 3.0518213473977828798, + 1.9692286411650965494, + 0.68408854039050825957, + 1.1269238219932133926, + -2.6312197636288825464, + -0.74334398169426096903, + -1.6728462595975237548, + -4.5277731890756109934, + 2.0394142452183401382, + -1.4677828109204844598, + 2.8071790565928202987, + 2.6558903870346637355, + -4.1710887662639057893, + 2.8206050038847387817, + 2.1170071154749972031, + 0.54806101255802652794, + -1.5114297743564342191, + 0.11532237677727565084, + -1.9704061919624336063, + 0.81301711728032177717, + 0.9545086499966127791, + 0.45826792051469911193, + 1.2195869429760046732, + -4.2594350561452678505, + -0.64174811370623130458, + 0.86184766619713892855, + 1.6746818427659309059, + -0.62475945690155054724, + -1.8575118942617874218, + ] + ) + + # Forward pass + Q = x1.shape[1] + xp1 = mapminmax_apply(x1, x1_step1) + a1 = tansig(np.outer(b1, np.ones(Q)) + IW1_1 @ xp1) + a2 = tansig(b2 + LW2_1 @ a1) + y1 = mapminmax_reverse(a2, y1_step1) + + # Denormalize output + minOutput = 2032.1701 + maxOutput = 3961.0986 + y1 = y1.T * (maxOutput - minOutput) + minOutput + + return y1 + + +def ANN_DEL_Shaft(x1): + x1 = np.array(x1, dtype=np.float64) + if x1.ndim == 1: + x1 = x1.reshape(1, -1) + if x1.shape[1] != 10: + raise ValueError("Input must have shape (Q, 10)") + + # Normalize input + minInputs = np.array( + [ + 3.36093, + 3.43696, + 3.36454, + 3.41895, + 8.07273, + 8.23081, + 8.67988, + 8.44285, + -30, + 60, + ] + ) + maxInputs = np.array( + [14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100] + ) + x1 = (x1 - minInputs) / (maxInputs - minInputs) + x1 = x1.T # (10, Q) + + # Preprocessing settings + x1_step1 = { + "xoffset": np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), + "gain": np.array( + [2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2] + ), + "ymin": -1, + } + + y1_step1 = { + "ymin": -1, + "gain": 2.00005958996671, + "xoffset": 2.97940956388248e-05, + } + + # Neural net weights (Layer 1 and 2) + b1 = np.array( + [ + 0.36973714546627450828, + -0.2066562536488118218, + -1.2988302392304444943, + -1.4435895707515138398, + -0.010802024206083797944, + -2.3899966461222872383, + 0.36426392552094405408, + 0.84628174977270587132, + -0.3187031579076420873, + -0.22975199897261461279, + -0.80519717630601184144, + -2.847600099914933125, + 0.097801438673709342742, + -0.55286018245702917007, + -0.74537839263274052737, + 0.18275120755000179296, + -0.83612183587527588724, + 1.8137511868726416964, + -0.06344248016922769684, + -0.43525721627285762771, + 1.9237001993929312427, + -0.54478844882657939674, + 0.85710389730488767412, + -0.50316178163479408081, + 1.7871489190287248583, + -0.31411324429323972396, + -0.77629837332384876714, + 0.86648835567982862571, + 0.40294040984103368652, + -0.59540311860738892591, + ] + ) + + b2 = -0.66528588255028775489 + + IW1_1 = np.array( + [ + [ + -0.22596362855224216837, + -0.91532708630097092684, + 1.6053694039234931434, + -0.20226031232594993137, + 1.3976131170121923741, + -0.25352835992364780582, + 1.6358731200215437251, + -1.183739760899431781, + -0.40334538928668384195, + 0.32031204596573287224, + ], + [ + 0.053364762754089030417, + -0.94023268863634468229, + 0.19280790965390182112, + 0.4382481530448716911, + 0.61266667303577082571, + 0.40311348714698680418, + -0.036741223146806355204, + -0.19653075801532124411, + 0.93751579829856612758, + -0.15485487860197952315, + ], + [ + 0.69086204650031834973, + 0.016128612307716228003, + 1.1212958388613536442, + -0.49539422853664100144, + 0.56341858227430541284, + -0.46163801788783359603, + 0.53382640995620866953, + -0.66020739489853830229, + -0.26461525164359162021, + 0.54643424737345358544, + ], + [ + 2.4701446322666660294, + -0.87272983677107762723, + -1.0280742800962285877, + 0.26277839602798480634, + 0.81160211771776680223, + 0.81300991215792328681, + -3.0642177234535434849, + -0.88854293927559946376, + 0.23799304327475248599, + 0.15641589648532305823, + ], + [ + 2.7417660554088754132, + -4.5293212200884838126, + 0.29984809847021509643, + 1.3163514165129333033, + 0.45525595977516741808, + 1.1167552273771437221, + -1.3761914759327313895, + 0.058311893270782164111, + 0.041234201276880697029, + 0.0051545947704693551722, + ], + [ + 1.0907229741091744035, + 0.26856391853175604068, + 0.82681184785541250726, + 0.61471435545672958867, + -0.19399514712494062008, + 0.63750572094885626928, + -0.53213184756022624544, + -0.31114335760920969198, + 1.6685101177075778445, + -0.9218378420349089275, + ], + [ + 2.043020743703385822, + -3.8997923331515695899, + 2.9166104587923569191, + -0.6919423228107091095, + -2.0674844473788254184, + -1.0331609425025911619, + 0.42584407407665930689, + 2.5594779630056807562, + 0.024446626576142365533, + -0.010600969684752263589, + ], + [ + -0.70410021070750949956, + -0.23801491134342867007, + -1.7084895454148742999, + 1.0049878344962155374, + 0.5246301718785434387, + -0.78615683000937919278, + -0.13400274727776989581, + 0.89984576012301675796, + 0.80359711368847397406, + -0.11222808156573686744, + ], + [ + 0.56174152224378859355, + -1.3948167101415234193, + 1.2116871414393084461, + -0.31042120670105272096, + -0.15760175350391258942, + 1.0908781887056613336, + -0.31296414864659127808, + 0.73778774854116790927, + 0.54266287559244874572, + -1.0835422431153651779, + ], + [ + -0.41481029156252052781, + 0.40948534324850577315, + 0.6448605462044215697, + 0.057999211357080776574, + 0.81409334427263413403, + -0.26350574909826335324, + -0.34215724729462554388, + -0.53180612475628508129, + 0.50532826287396626075, + 0.30076171369712356718, + ], + [ + 0.53920224748374601109, + 1.4727921500715224212, + 0.52657049741913763974, + -0.51954585804837993823, + 0.54724793289710771393, + 0.79549808721351522589, + -0.13751447675611055965, + -1.0390470670993550151, + -0.3008926792405013928, + 0.48235594703173928499, + ], + [ + 1.0214326504845487875, + 0.26744510661405207497, + 1.3788567676639484905, + 0.57976382885810251455, + -0.060102982299375440345, + -0.42283039774164077329, + 0.32024915163266776119, + -0.68916335657658844838, + 1.8558628514286568123, + -1.1483026733902301775, + ], + [ + -1.3103317227167823322, + 2.5888128008682498304, + 0.81758276647056427056, + -2.1538275959477011234, + -0.77873236358559871917, + -1.2543827337965347546, + 1.646438241634666344, + 0.015383520638162666294, + -0.094913683719706667952, + -0.0076112818292794533898, + ], + [ + -0.98918180983500780812, + 1.2102660123610118337, + 0.012104992844632653931, + 0.068020046560899855015, + -0.25604652723108750623, + -0.95318341958713204143, + 0.7145865432089544278, + -0.1721042853718079968, + -0.034244098957857578569, + -0.11238383903263039765, + ], + [ + 1.8762990659881091382, + -0.26028551057633736443, + 0.5728874134952501862, + -1.6970758958997567145, + 0.73639176783705484475, + -0.76740038188014292331, + 1.5927012544907173108, + -0.87640404551816708523, + -0.0032476555049604427169, + -0.47747982989677273391, + ], + [ + 0.25110566526649863439, + -1.6035622558892523859, + 1.6555914900962498404, + -0.16333428149878143065, + -2.0817497512681439886, + -0.58920657425237410454, + 0.60310430865801500921, + 2.2249948316502012879, + 0.023775714036231486437, + -0.0045188669493590538986, + ], + [ + 0.20639941129035185852, + 0.21846835702510242205, + -0.84613348301684709885, + -0.73237404108368064914, + 0.28440002164416094965, + 0.040494096088159285685, + 0.35861770331024822589, + -0.41921079962006102537, + 0.38624005520163107175, + -0.21211538131929158491, + ], + [ + 1.2109929236010323894, + -0.09528230178205696066, + -0.5434759981622728775, + -0.84007768963176776555, + 0.51651308452225919154, + 2.4959778737421367545, + -0.54075109423726652746, + 1.0666270557519299533, + 0.222606643351003608, + -0.16502433194489202206, + ], + [ + -0.22016734136802268429, + -1.6175707804270178514, + 1.2545846923170584919, + 0.47749471429579809501, + 0.97480111327280960509, + 0.6435634042787164999, + 0.37943140969178029698, + -1.1374507511168598928, + 1.192596129991261078, + -0.22948152830346796316, + ], + [ + -0.71933973881502555336, + 0.5159530874493316599, + -0.18198198199902915206, + -0.11304641282764192611, + -0.95539632241778527089, + -0.68935978599406610989, + 0.08845525913281167274, + 0.30943303937811628135, + 0.077997655488309031169, + -0.13869982515565257297, + ], + [ + 2.743192211562484939, + -1.6899393494708603303, + 0.39676889449374724839, + -1.8939188400960362824, + 1.2631697338709126921, + 1.9583721850904562967, + -0.01148934079678747347, + 0.63503350994572671517, + 0.34086434801906828618, + -0.21420153043508222135, + ], + [ + -0.13216116601482724713, + 0.43914882335712196459, + 0.55692929554782111268, + -0.47087842669969026677, + 0.15873736936906288064, + 0.20233949616233731783, + -0.55120420641509271231, + -0.45618694254317132541, + 0.023280546835997496108, + 0.5620874633060756187, + ], + [ + -1.3722732297515842781, + -0.27721710290630813267, + 1.1755723903183301626, + -0.84319474430960650313, + -0.59571629042205997973, + -1.3103621815595212219, + 2.6831751452187169171, + 0.5184640923425669623, + -0.30660224370987443354, + -0.15188061954612286364, + ], + [ + -0.10794750095889575625, + 0.89602586950785001463, + -0.32932640112089250906, + 1.0497276601165768106, + 0.64036175754688462458, + 0.34218570116207830401, + -1.2992950786954726716, + -0.57318324238504847479, + 0.5386680375794015152, + 0.075149690974339905525, + ], + [ + 1.2047277977408590299, + -2.6422625228417970789, + -0.53578198910222696316, + -0.38572910492911094416, + -0.061923290647390286101, + 0.25450410987074906233, + 1.402180937764335722, + -0.38598465654084346266, + 0.27893698225387331124, + -1.2937387443729693182, + ], + [ + -0.6728183034692223341, + 2.5069058731502615878, + -1.0851782631003821233, + 0.13225315301548967728, + -0.78739832949226629122, + 0.10449652496830340309, + 0.085808588551291142821, + -0.26321598073472407542, + -0.20664055377807968861, + -0.60953313775325945745, + ], + [ + 1.2519326161029409317, + -1.2573353404551559365, + 1.3277965719711088965, + -0.4926427503374136152, + -0.68355017952670849013, + 0.10234543260001956189, + 0.52116680288380945463, + -0.35073647311021388662, + -2.2273127831132000232, + -0.20202235290056480554, + ], + [ + -0.61664915108971751767, + 0.3250030914647741298, + -1.0397974693069071961, + 0.43017594580423795803, + 1.0101042230421541923, + -0.14528182746006354509, + -0.54561222928297958834, + 0.2547058161792747355, + 1.136913445510474352, + -0.0034537045816362111315, + ], + [ + 0.31583108240361085217, + -1.6729392138176779614, + -0.94217145556820758312, + 0.6835377561472921748, + 0.33698555277136965636, + -0.085754924092076786901, + 0.061023058111186502528, + 0.70443818045762962576, + 0.46705637183662479517, + -0.98912595962722460463, + ], + [ + -0.0085651289843365271959, + -1.3948435779648364896, + 1.1155103971336253199, + 1.0261034352062423647, + 0.77302343314135557595, + -0.6826613475445155732, + -0.57660305254983212908, + 0.83502513288418933612, + 0.57754090435467941855, + 0.71312408787937731081, + ], + ] + ) + + LW2_1 = np.array( + [ + 0.51391909773924471239, + 1.4475365934423036762, + 2.5730844906045224896, + -1.3520850985614496498, + -1.7205613642369950167, + -1.5361393482802987442, + -1.9183880880427215398, + -1.4986228340863947395, + -0.68801018794281110225, + 1.7007536540106982237, + -1.5590168038577709719, + 1.1622849259631440333, + -2.1666035543791326567, + -3.6314213126305485702, + 1.0666578268445148225, + 2.4804750328017939331, + -1.8178665287810888973, + -1.8374891186652426711, + -0.59119243351515926577, + 1.8573733290251603911, + 1.3794256747906468163, + -2.4618250429577472893, + -2.0847359364348454491, + -1.243323277123661752, + -0.42420896499956795012, + 0.9666791564507416501, + 0.38132486426661010848, + 1.7617089337834785923, + -0.90999353062514065638, + -0.71363409422530532655, + ] + ) + + # Forward pass + Q = x1.shape[1] + xp1 = mapminmax_apply(x1, x1_step1) + a1 = tansig(np.outer(b1, np.ones(Q)) + IW1_1 @ xp1) + a2 = tansig(b2 + LW2_1 @ a1) + y1 = mapminmax_reverse(a2, y1_step1) + + # Denormalize output + minOutput = 208.9038 + maxOutput = 1978.193 + y1 = y1.T * (maxOutput - minOutput) + minOutput + + return y1 + def ANN_DEL_TowerBase(x1): x1 = np.array(x1, dtype=np.float64) @@ -17,38 +1015,478 @@ def ANN_DEL_TowerBase(x1): raise ValueError("Input must have shape (Q, 10)") # Normalize input - minInputs = np.array([3.36093, 3.43696, 3.36454, 3.41895, 8.07273, 8.23081, 8.67988, 8.44285, -30, 60]) - maxInputs = np.array([14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100]) + minInputs = np.array( + [ + 3.36093, + 3.43696, + 3.36454, + 3.41895, + 8.07273, + 8.23081, + 8.67988, + 8.44285, + -30, + 60, + ] + ) + maxInputs = np.array( + [14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100] + ) x1 = (x1 - minInputs) / (maxInputs - minInputs) x1 = x1.T # (10, Q) # Preprocessing settings x1_step1 = { - 'xoffset': np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), - 'gain': np.array([2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2]), - 'ymin': -1 + "xoffset": np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), + "gain": np.array( + [2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2] + ), + "ymin": -1, } y1_step1 = { - 'ymin': -1, - 'gain': 2.00004639898127, - 'xoffset': 2.31989524333902e-05 + "ymin": -1, + "gain": 2.00004639898127, + "xoffset": 2.31989524333902e-05, } # Neural net weights (Layer 1 and 2) - b1 = np.array([ - -0.84162497711391714983,3.2926011373061605525,-3.5555455227097665372,-2.6479150716657304798,0.084908405569389278078,0.88102627456951254636,2.9098095957856964233,-1.5365347904503441345,0.42826877638142596405,3.7171892968014179637,-1.1267062983954521105,-3.1692161198502097896,0.44862185363865647592,0.0059798061670441465809,0.083920952379510360686,0.84092501379816608775,2.1711005707576713775,-4.2343657978014039855,-3.1293738202409504545,0.8873338206250047655,2.2666187777019515259,-0.62458140282536833698,-0.23835990419030628207,0.98971293975353968886,-2.1000912255506865023,-3.5606715080021755782,0.90417012266854923652,3.5767824884756058701,1.5345881333002955316,2.3094900541204097522 - ]) + b1 = np.array( + [ + -0.84162497711391714983, + 3.2926011373061605525, + -3.5555455227097665372, + -2.6479150716657304798, + 0.084908405569389278078, + 0.88102627456951254636, + 2.9098095957856964233, + -1.5365347904503441345, + 0.42826877638142596405, + 3.7171892968014179637, + -1.1267062983954521105, + -3.1692161198502097896, + 0.44862185363865647592, + 0.0059798061670441465809, + 0.083920952379510360686, + 0.84092501379816608775, + 2.1711005707576713775, + -4.2343657978014039855, + -3.1293738202409504545, + 0.8873338206250047655, + 2.2666187777019515259, + -0.62458140282536833698, + -0.23835990419030628207, + 0.98971293975353968886, + -2.1000912255506865023, + -3.5606715080021755782, + 0.90417012266854923652, + 3.5767824884756058701, + 1.5345881333002955316, + 2.3094900541204097522, + ] + ) b2 = -2.3006747078844167476 - IW1_1 = np.array([ - [-0.73314577044910178572,2.8287129130879797856,1.5877100060823403638,-0.41655991975409656369,0.097273890561228509855,0.76547073400483855998,-1.2822206037597951855,-1.3358392133678875791,-0.75065359840991330298,0.64663836274125341408],[1.5248642827357874463,-3.2314794316994297496,1.7278966231683206001,-0.30298572995397865526,0.72700476184016593617,-2.4564350290640657448,1.2808746935876647033,1.0053487209660716406,-0.054567809167083515531,2.7209768015275499486],[0.28835782282312688585,0.25196266795202981736,1.5602359578309927812,-3.0230108648302662644,-0.46104540051838283077,-2.5096224768534929339,1.8853499774504214326,-1.8512802123437130941,-0.0072108241588582930662,-0.23041967859359976933],[-0.77415367781163335614,3.7163062420508929939,-1.7509315664897189269,2.2506471323660499628,1.3290157563979454469,1.668059995930878614,-1.656422715963739023,-1.7085589114292070168,0.17422791589944844337,-3.6101746277618049774],[-1.5303513485698256869,-2.2748699140834407473,-0.91430462986787142121,1.7031083422226245272,-1.0828816400584695412,-0.98542555894232819469,0.1037276115815981975,1.7918445566763228083,-0.53784741045856254704,-0.65362886661162244994],[0.86522561103239303826,-1.8979878431754679813,-2.3638324849762319957,0.25618629740205128842,-0.059741699719734336904,0.10475601801469008878,0.35154240163984706857,1.2612971924108209443,0.6365349018892197952,-0.38892026926383943541],[-0.79717951130863318188,-1.7866528049116900956,2.4630215876678649423,-0.63913856292888571176,-1.3893773844656016614,2.7079192256023270069,-0.29125661831644727995,0.13478783801792221242,-0.44499658388473051218,3.9724902927789829121],[-2.1468840572278589107,0.9352703755387399287,0.10132770290081988263,1.6253429772440892709,-1.5216428365117817822,0.34863189459131382897,0.78567121687563556964,0.45414027770947434925,-1.9967742903415643951,0.0075970659915833233314],[-1.9622237832898525856,-0.5196275506754268747,-0.49067931899208472313,1.2703957847195881392,-1.8868740078256549531,-0.20321123936136653576,0.0068393333651150496968,1.7858073874806812409,0.73084644335656956393,0.25064528334787483654],[-0.16962473066216168793,-0.4820412910738208212,-2.6667827849934657714,0.26643678314280849762,-0.36396044205020244844,0.70354451187386890521,-1.5070895182316543792,0.64104650725093792474,-0.097743213540430612385,0.23728513777661014439],[-2.0410554283327249081,2.2409875745842300354,-3.3692409145696964323,1.7992726503941134375,3.3360986881249572455,-5.2815551713305204373,-1.3296212797003796879,1.2217429384131801573,-0.841507297175366209,0.13936158729076444929],[0.59573552422161712983,1.0939268284690140121,-0.24821226448753863636,0.90249206043346508199,0.048884521935790486991,-1.4927503391566487867,0.58494801191213108282,0.40293803933450045296,0.17579573810353754659,-2.2565382839985974606],[-3.003217538438221812,0.16689719881148923353,-1.2072341549677467754,2.0989368812931874508,-2.68828044483559081,0.089789187146049623256,-0.16780514782287364595,2.2298591801516303157,1.0816517634306781481,0.26847677909972939014],[2.6007224902676857603,-1.5841599436197115747,1.8033171593410857181,2.0662802370864552515,3.2229726791544019981,-2.742900728157287471,-3.2680040921810036281,0.020717209114053735525,-0.28595515157999523703,0.88902634377574718538],[-0.067806483816461329828,-0.57044263506227277372,1.1596014169837842722,0.22113257571278469027,0.025387590261853096307,-0.49286048374576491016,0.54304076803663392514,0.71064831385637960981,-0.10417223206974035588,-0.0025451527067482113478],[1.9733901389574612928,-3.2211131674174855455,1.1553484290512952004,-0.32229981685833380967,0.75261550666368293161,0.45250230577624950268,-1.1797606942277811815,0.49268093789963707252,0.055928184884686579781,-0.6466276570214183339],[2.1847194209233151696,7.4799445854895623143,1.5008151177392070608,-3.3893475854617975962,2.8026167156034351713,2.2073081660885587318,-1.059301959052601827,-3.9302991003224576616,-0.31168274003645601855,1.0023442035188014909],[-1.0012822675596795285,3.7786570396212719736,-1.5391187983334853051,1.5082231272932171695,0.5076885950058169783,2.0380125949109095806,-1.3192904728872731912,-1.4180004251489104483,0.12633077863470865143,-5.0929504755238381719],[-0.18304627197124528903,1.3400325149043699202,-0.89837235922567637569,-0.42078675394242837093,-0.33093212532440458018,-0.7408115596344096998,0.084676027605090173345,-0.98978975904575450251,0.21340927653231867023,-3.1407006287918259879],[2.5193387728473868314,-3.821493486297629083,1.232898839455989437,-0.41211507135204644703,0.93699545365185632484,0.36778373291199067951,-1.2594672431583939787,0.21790666959494661703,0.034140035264000945237,-0.60795236236146654729],[1.3082123553016988815,-3.4381035623023232795,2.7517699733229936676,-0.90629246020718257082,-1.2583091138186555114,-0.20045348812031213437,2.3224016497084756239,2.427759365760023158,-0.48742028493485195506,-0.43576489225969350372],[2.0247588002476799574,-5.7672863071503455146,2.9059326525086923709,-3.0885347866530961092,1.1718578695820622837,-1.1999946584458376364,0.50100566576652905137,-0.015360673044539016607,0.10151112197513319224,0.4356303017492557661],[-0.93393218008519962581,0.64171898024523155168,1.023475356251981605,0.76994444322229005362,0.0017456347202525939258,-0.68139090263893797861,0.61126408278564436927,0.81643466536731568173,0.014151016775331910422,-0.086222718181227217538],[1.8183996949330099024,-1.7967012399631754338,-2.7511476216865724531,-0.51109837604499930297,0.79887842815691212373,0.27193910857010389348,-0.1902934397636798225,0.82527332004905529228,0.65955179319892687229,-0.16076368288437462017],[-1.2246223321522089478,-0.69509471386913646018,-0.42086785651448577195,-0.49097759089980991254,-0.4865173574821159419,0.28812302580508780681,-0.045462622534334709568,0.093102031617319419565,0.19333531890690489052,0.012094259414969908695],[-0.54101497318564562011,1.2388363152547523516,-0.30955098884267412407,-1.392671060071018152,-0.41859130758748908097,-1.317798628211867662,0.78919075197092092289,-2.0879724454419670288,0.097897549005229261843,-0.14961949963903720118],[1.4177445562189072703,-0.82515637413414044676,0.88588242220425783557,-0.34037545844659078398,0.31647122672771083041,-0.23094740010168765543,0.22799798175246874243,0.095345910302176886675,-0.97966442188203683994,-0.0092327981091944264641],[-2.2112173391171525694,-1.8611402239423604499,-2.3948251375710736255,2.1189191474442701235,-2.4741654686139198382,0.88603393775006400457,4.1079702530789621306,-2.9367523072645185245,1.1592749369028840789,1.3701901834073804132],[0.93143002684612163922,-0.14344885948265617692,1.1995637416196398561,0.28328117071913810898,0.45140818370239166324,-0.75852423832135040804,0.38185990585530588115,0.54079499622638393941,0.044295733610979950989,-0.037952765478541115873],[0.19243565191640349399,-1.4366255458599905825,1.1866271182270113904,-0.48875760449992750045,-0.70944926486675308208,0.36540425943677817822,0.84621843351843117897,2.0413312531345848555,-0.18591285470335938701,-0.56987556083528989603] - ]) + IW1_1 = np.array( + [ + [ + -0.73314577044910178572, + 2.8287129130879797856, + 1.5877100060823403638, + -0.41655991975409656369, + 0.097273890561228509855, + 0.76547073400483855998, + -1.2822206037597951855, + -1.3358392133678875791, + -0.75065359840991330298, + 0.64663836274125341408, + ], + [ + 1.5248642827357874463, + -3.2314794316994297496, + 1.7278966231683206001, + -0.30298572995397865526, + 0.72700476184016593617, + -2.4564350290640657448, + 1.2808746935876647033, + 1.0053487209660716406, + -0.054567809167083515531, + 2.7209768015275499486, + ], + [ + 0.28835782282312688585, + 0.25196266795202981736, + 1.5602359578309927812, + -3.0230108648302662644, + -0.46104540051838283077, + -2.5096224768534929339, + 1.8853499774504214326, + -1.8512802123437130941, + -0.0072108241588582930662, + -0.23041967859359976933, + ], + [ + -0.77415367781163335614, + 3.7163062420508929939, + -1.7509315664897189269, + 2.2506471323660499628, + 1.3290157563979454469, + 1.668059995930878614, + -1.656422715963739023, + -1.7085589114292070168, + 0.17422791589944844337, + -3.6101746277618049774, + ], + [ + -1.5303513485698256869, + -2.2748699140834407473, + -0.91430462986787142121, + 1.7031083422226245272, + -1.0828816400584695412, + -0.98542555894232819469, + 0.1037276115815981975, + 1.7918445566763228083, + -0.53784741045856254704, + -0.65362886661162244994, + ], + [ + 0.86522561103239303826, + -1.8979878431754679813, + -2.3638324849762319957, + 0.25618629740205128842, + -0.059741699719734336904, + 0.10475601801469008878, + 0.35154240163984706857, + 1.2612971924108209443, + 0.6365349018892197952, + -0.38892026926383943541, + ], + [ + -0.79717951130863318188, + -1.7866528049116900956, + 2.4630215876678649423, + -0.63913856292888571176, + -1.3893773844656016614, + 2.7079192256023270069, + -0.29125661831644727995, + 0.13478783801792221242, + -0.44499658388473051218, + 3.9724902927789829121, + ], + [ + -2.1468840572278589107, + 0.9352703755387399287, + 0.10132770290081988263, + 1.6253429772440892709, + -1.5216428365117817822, + 0.34863189459131382897, + 0.78567121687563556964, + 0.45414027770947434925, + -1.9967742903415643951, + 0.0075970659915833233314, + ], + [ + -1.9622237832898525856, + -0.5196275506754268747, + -0.49067931899208472313, + 1.2703957847195881392, + -1.8868740078256549531, + -0.20321123936136653576, + 0.0068393333651150496968, + 1.7858073874806812409, + 0.73084644335656956393, + 0.25064528334787483654, + ], + [ + -0.16962473066216168793, + -0.4820412910738208212, + -2.6667827849934657714, + 0.26643678314280849762, + -0.36396044205020244844, + 0.70354451187386890521, + -1.5070895182316543792, + 0.64104650725093792474, + -0.097743213540430612385, + 0.23728513777661014439, + ], + [ + -2.0410554283327249081, + 2.2409875745842300354, + -3.3692409145696964323, + 1.7992726503941134375, + 3.3360986881249572455, + -5.2815551713305204373, + -1.3296212797003796879, + 1.2217429384131801573, + -0.841507297175366209, + 0.13936158729076444929, + ], + [ + 0.59573552422161712983, + 1.0939268284690140121, + -0.24821226448753863636, + 0.90249206043346508199, + 0.048884521935790486991, + -1.4927503391566487867, + 0.58494801191213108282, + 0.40293803933450045296, + 0.17579573810353754659, + -2.2565382839985974606, + ], + [ + -3.003217538438221812, + 0.16689719881148923353, + -1.2072341549677467754, + 2.0989368812931874508, + -2.68828044483559081, + 0.089789187146049623256, + -0.16780514782287364595, + 2.2298591801516303157, + 1.0816517634306781481, + 0.26847677909972939014, + ], + [ + 2.6007224902676857603, + -1.5841599436197115747, + 1.8033171593410857181, + 2.0662802370864552515, + 3.2229726791544019981, + -2.742900728157287471, + -3.2680040921810036281, + 0.020717209114053735525, + -0.28595515157999523703, + 0.88902634377574718538, + ], + [ + -0.067806483816461329828, + -0.57044263506227277372, + 1.1596014169837842722, + 0.22113257571278469027, + 0.025387590261853096307, + -0.49286048374576491016, + 0.54304076803663392514, + 0.71064831385637960981, + -0.10417223206974035588, + -0.0025451527067482113478, + ], + [ + 1.9733901389574612928, + -3.2211131674174855455, + 1.1553484290512952004, + -0.32229981685833380967, + 0.75261550666368293161, + 0.45250230577624950268, + -1.1797606942277811815, + 0.49268093789963707252, + 0.055928184884686579781, + -0.6466276570214183339, + ], + [ + 2.1847194209233151696, + 7.4799445854895623143, + 1.5008151177392070608, + -3.3893475854617975962, + 2.8026167156034351713, + 2.2073081660885587318, + -1.059301959052601827, + -3.9302991003224576616, + -0.31168274003645601855, + 1.0023442035188014909, + ], + [ + -1.0012822675596795285, + 3.7786570396212719736, + -1.5391187983334853051, + 1.5082231272932171695, + 0.5076885950058169783, + 2.0380125949109095806, + -1.3192904728872731912, + -1.4180004251489104483, + 0.12633077863470865143, + -5.0929504755238381719, + ], + [ + -0.18304627197124528903, + 1.3400325149043699202, + -0.89837235922567637569, + -0.42078675394242837093, + -0.33093212532440458018, + -0.7408115596344096998, + 0.084676027605090173345, + -0.98978975904575450251, + 0.21340927653231867023, + -3.1407006287918259879, + ], + [ + 2.5193387728473868314, + -3.821493486297629083, + 1.232898839455989437, + -0.41211507135204644703, + 0.93699545365185632484, + 0.36778373291199067951, + -1.2594672431583939787, + 0.21790666959494661703, + 0.034140035264000945237, + -0.60795236236146654729, + ], + [ + 1.3082123553016988815, + -3.4381035623023232795, + 2.7517699733229936676, + -0.90629246020718257082, + -1.2583091138186555114, + -0.20045348812031213437, + 2.3224016497084756239, + 2.427759365760023158, + -0.48742028493485195506, + -0.43576489225969350372, + ], + [ + 2.0247588002476799574, + -5.7672863071503455146, + 2.9059326525086923709, + -3.0885347866530961092, + 1.1718578695820622837, + -1.1999946584458376364, + 0.50100566576652905137, + -0.015360673044539016607, + 0.10151112197513319224, + 0.4356303017492557661, + ], + [ + -0.93393218008519962581, + 0.64171898024523155168, + 1.023475356251981605, + 0.76994444322229005362, + 0.0017456347202525939258, + -0.68139090263893797861, + 0.61126408278564436927, + 0.81643466536731568173, + 0.014151016775331910422, + -0.086222718181227217538, + ], + [ + 1.8183996949330099024, + -1.7967012399631754338, + -2.7511476216865724531, + -0.51109837604499930297, + 0.79887842815691212373, + 0.27193910857010389348, + -0.1902934397636798225, + 0.82527332004905529228, + 0.65955179319892687229, + -0.16076368288437462017, + ], + [ + -1.2246223321522089478, + -0.69509471386913646018, + -0.42086785651448577195, + -0.49097759089980991254, + -0.4865173574821159419, + 0.28812302580508780681, + -0.045462622534334709568, + 0.093102031617319419565, + 0.19333531890690489052, + 0.012094259414969908695, + ], + [ + -0.54101497318564562011, + 1.2388363152547523516, + -0.30955098884267412407, + -1.392671060071018152, + -0.41859130758748908097, + -1.317798628211867662, + 0.78919075197092092289, + -2.0879724454419670288, + 0.097897549005229261843, + -0.14961949963903720118, + ], + [ + 1.4177445562189072703, + -0.82515637413414044676, + 0.88588242220425783557, + -0.34037545844659078398, + 0.31647122672771083041, + -0.23094740010168765543, + 0.22799798175246874243, + 0.095345910302176886675, + -0.97966442188203683994, + -0.0092327981091944264641, + ], + [ + -2.2112173391171525694, + -1.8611402239423604499, + -2.3948251375710736255, + 2.1189191474442701235, + -2.4741654686139198382, + 0.88603393775006400457, + 4.1079702530789621306, + -2.9367523072645185245, + 1.1592749369028840789, + 1.3701901834073804132, + ], + [ + 0.93143002684612163922, + -0.14344885948265617692, + 1.1995637416196398561, + 0.28328117071913810898, + 0.45140818370239166324, + -0.75852423832135040804, + 0.38185990585530588115, + 0.54079499622638393941, + 0.044295733610979950989, + -0.037952765478541115873, + ], + [ + 0.19243565191640349399, + -1.4366255458599905825, + 1.1866271182270113904, + -0.48875760449992750045, + -0.70944926486675308208, + 0.36540425943677817822, + 0.84621843351843117897, + 2.0413312531345848555, + -0.18591285470335938701, + -0.56987556083528989603, + ], + ] + ) - LW2_1 = np.array([ - -1.5215356135284230366,-1.6873883124842390391,2.0336088364213265045,2.6545247035270689295,0.67160716513933493843,-3.1828666758077464038,-0.35635939569553681805,-0.33893787265169356138,-3.0241455728900232813,1.62923025968103663,0.14749904795098447985,1.3144064013359400001,1.9046511649408164324,0.13075523505242278577,4.3909186600635399245,1.9474791474145720649,0.34986448736695469064,-3.9349793399422487994,-0.64947227496624837517,-1.9724256225350846883,0.61284660942039126397,-0.66138775495356272316,-2.6816093520633064173,1.6214899539771308046,-3.7559955941453302408,-3.9550864584222495957,-1.4666535406999394731,0.10995980227284518627,-3.4955477027595240891,-1.0646902469579164752 - ]) + LW2_1 = np.array( + [ + -1.5215356135284230366, + -1.6873883124842390391, + 2.0336088364213265045, + 2.6545247035270689295, + 0.67160716513933493843, + -3.1828666758077464038, + -0.35635939569553681805, + -0.33893787265169356138, + -3.0241455728900232813, + 1.62923025968103663, + 0.14749904795098447985, + 1.3144064013359400001, + 1.9046511649408164324, + 0.13075523505242278577, + 4.3909186600635399245, + 1.9474791474145720649, + 0.34986448736695469064, + -3.9349793399422487994, + -0.64947227496624837517, + -1.9724256225350846883, + 0.61284660942039126397, + -0.66138775495356272316, + -2.6816093520633064173, + 1.6214899539771308046, + -3.7559955941453302408, + -3.9550864584222495957, + -1.4666535406999394731, + 0.10995980227284518627, + -3.4955477027595240891, + -1.0646902469579164752, + ] + ) # Forward pass Q = x1.shape[1] @@ -64,57 +1502,498 @@ def ANN_DEL_TowerBase(x1): return y1 -def ANN_DEL_BladeRoot(x1): + +def ANN_DEL_YawBearings(x1): x1 = np.array(x1, dtype=np.float64) if x1.ndim == 1: x1 = x1.reshape(1, -1) if x1.shape[1] != 10: raise ValueError("Input must have shape (Q, 10)") - + # Normalize input - minInputs = np.array([3.36093, 3.43696, 3.36454, 3.41895, 8.07273, 8.23081, 8.67988, 8.44285, -30, 60]) - maxInputs = np.array([14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100]) + minInputs = np.array( + [ + 3.36093, + 3.43696, + 3.36454, + 3.41895, + 8.07273, + 8.23081, + 8.67988, + 8.44285, + -30, + 60, + ] + ) + maxInputs = np.array( + [14.505, 13.7296, 13.1378, 13.6877, 34.8086, 38.3538, 37.5428, 35.6964, 30, 100] + ) x1 = (x1 - minInputs) / (maxInputs - minInputs) x1 = x1.T # (10, Q) - + # Preprocessing settings x1_step1 = { - 'xoffset': np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), - 'gain': np.array([2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2]), - 'ymin': -1 + "xoffset": np.array([0, 0, 0, 0.0062108, 0.00031595, 0, 9.7989e-05, 0, 0, 0]), + "gain": np.array( + [2.0001, 2, 2.0025, 2.0125, 2.0006, 2.0768, 2.0627, 2.0816, 2, 2] + ), + "ymin": -1, } - + y1_step1 = { - 'ymin': -1, - 'gain': 2.06245121975435, - 'xoffset': 0 + "ymin": -1, + "gain": 2, + "xoffset": 0, } - + # Neural net weights (Layer 1 and 2) - b1 = np.array([ - 0.54366944462409116934,0.31294379591009785502,-0.51189926508535932292,1.4881933190659204502,-0.6288956595742227762,-0.19359627640225313128,0.39137621590253535153,-1.0366649402122289914,0.55534527483506990198,0.18839221921288695771,-0.078706228422190604999,0.046792462423330301313,0.69232199957340845309,-0.74109280839050772904,-5.4456938554121316898,-0.080904369300827672085,-1.4551520598122729133,0.80313766438230504985,-0.13330255544478317176,-1.941023842180298109,1.6791433222290104155,1.2403777148882095815,-1.8054044309269281499,-0.10233143369148571533,0.79884202496933298665,-0.87816344068184881699,-0.72496721667128649624,-0.58219149095682520834,1.0472757666203991178,-0.3205217551283675026 - ]) - - b2 = -0.11631999509276053084 - - IW1_1 = np.array([ - [-0.9691541463169519588,-2.2082729161680534347,0.16322708809662275775,-0.030756863950325008528,-1.0668806280715801282,-0.28313582544797699647,1.4448560046137648438,0.032219573319804545308,0.25171283771525176931,-0.17830776446566862226],[-0.27228457256496318983,0.3785601780705833419,0.98266246214658969915,-1.3002810761955083674,-0.59192836496933864954,0.41117076156796644737,0.65150623661735718173,0.051330444549634708651,-0.46355296447057908749,-0.091790529001709156298],[1.086423022676347161,-0.55056610766413871527,0.027502769669224082227,1.1970701351400578893,1.293204485031062223,0.68504100358047015362,-2.6307913270293430408,0.95175716385282904675,-0.003006693817982381868,-0.18289221463576066373],[-0.27086973358198429551,1.9668420111618776236,2.073344235104797928,-0.37815115748314009902,0.031034569853559543923,0.39294666816021722733,1.4711446564972989748,-0.39087973432280370689,-0.051711373032646938686,-1.0508683142907673247],[-2.3707952492667327959,0.80069620830602927786,-1.1985705973028708549,-1.1271594560347750758,1.5479906631647339932,-0.76302763776628734771,0.11964566328780874838,-1.8307784479098603292,-0.06575321004638125244,-0.74589535016533248246],[0.22861523374558745392,-0.30551666836510621428,0.70528007692483773994,-0.21897051394009994785,0.38667705598732321493,0.32851840824230033045,0.18288952564016172642,-0.63396686470231611299,-0.51754919082022632359,-0.0034820766021412740895],[2.3561424580978442833,2.2681032820259843241,2.113918665617255499,-1.881036922676615708,-0.92943715409177052322,1.1749568861944190701,1.5570938607363293826,-0.33711975479166728098,0.11168831102751085316,-0.67485343036208744749],[-0.73364544036874212996,-0.87531583385826428056,1.2211284010742822215,0.67079957890499741779,0.068091287898962432612,-1.0348196946651282424,2.3906469772779046501,-1.747756061063288513,0.56268533373028373212,0.07973393811332304959],[0.21913089304261071377,1.0048470828366196095,-0.56728089234775902483,-1.2814967610504304218,-0.070467424528017588714,0.59743437336564553242,-1.1991834521803419467,0.84785982778085089429,-0.38418954858234133365,-0.063367996792277503371],[0.38238257660750030187,-1.5986421851254277726,-0.10573333916376159713,1.9496279169919061847,1.2867139392249535845,-0.17606069678139857348,-1.1507047525974840596,-0.18901790190493572563,0.66251721190207302215,0.085336100111380361333],[0.331800481834342742,-1.5085073941879851844,0.54449662178545166213,0.16440346954165099835,2.2587535147550066306,0.072497765193573898701,-1.4029161615611951408,-1.1273219005764036904,0.58577657017349327173,-0.21708439640900550893],[0.0090942014805446037828,2.0058526610487663611,-0.73664883685957416315,-1.9278553412925791832,-0.35464938529176925908,-0.10934821545468835502,0.23633872117319129624,0.21834430340219959654,-0.49006514257276378999,-0.081089762175526824972],[-1.1411976086703647937,-0.36481663214936238537,-0.39850948254482049249,-0.024895681856923042308,-1.1852946404874558084,0.35351002979606166443,0.79721041126107095032,-0.073634700495875060611,0.052426433188170390443,0.42058794228898904732],[0.47190044417647131203,-0.037889773969072837456,-1.2621561451633631634,0.68778546361877335169,0.18825936446146562808,1.0521269388873222272,-1.0867390289565972417,0.8183274318725353158,-0.033876635499573190535,-0.09502388360096158948],[0.55669774669443139459,3.0027684104964214029,0.40045869604030209787,0.92883946502768355291,4.1183864722698872995,-2.88294730843829905,2.3024854611343856803,3.0798604018907638213,0.35982651618929395454,0.4749359085730352481],[-0.93237508055082340963,-0.27291225495976745297,0.049393090857986578224,0.71248685845573545006,1.7923704541165901283,0.062034506301660234662,-1.0637860947322796967,-0.87927695587562360036,0.38576024582891432768,-0.22142151912150490056],[-1.2691077476496521736,-1.1867402146653003303,-2.1384502481696103793,1.065859627353023642,-0.48167446540824260248,0.066635866402156768151,-0.84750389620879051922,0.7055359190516925505,-0.22962234434907838332,0.59934675700423178935],[1.1459093098487915796,-0.58235794152739916996,3.1218756058823795563,-3.2532509447226272137,0.85125518731919758153,-2.125512469517314873,1.9789020460960036196,-1.9076761191135580553,-0.29694594227099480044,0.055091980110211519195],[0.088701574927947474114,-3.3998635154646130729,1.3233098139056098663,0.99068016840129979883,-1.2803161599652479463,-0.77116696798005579527,-2.3165734929254004903,0.66143191753427910129,0.013309392181332257987,1.0974885416793895843],[0.26991105171154072817,0.79089103942962690752,1.7406563340294087805,0.511381468956811025,-1.5137513068586612164,-1.1677363904868975908,1.9794293598478509555,0.46572973206621398612,-0.089833829810027091001,0.14819660128737038862],[0.99824650207053766682,1.0360546329400945886,-1.5895856530540735108,1.7245383977007640031,0.52572322657377812405,0.67910458688279262685,-1.182023049853849761,0.09104333676800291375,0.35469003514738067784,-0.12181382852712477338],[0.56214019008643079101,1.0745508138310606583,0.61312938827733465263,2.447985751329599502,-2.1998320803880888619,1.8748360217216732959,-0.66166231032422107017,2.4004555112192353938,0.026167820791865192831,0.5840463875785829595],[0.56465359716006746638,-0.9764957902556280489,-2.6241885196099414834,-0.77645480301266278644,0.64044861483177883965,0.021451528077588592758,-2.4581396730358702207,0.31020872458758308454,0.10863088515303774562,0.6486685177642154132],[2.3755911413073231842,-0.92494159162788791573,-0.16334825155607449187,-1.9312970205272603774,1.2127333286470038942,-1.5719539210160768938,0.53939222729209046481,-1.3703694200819782623,-0.30199023525727608508,0.032666268661235745019],[-0.99109827312085829742,-1.378883390133445408,-0.25527439695746484416,0.27070735177912941261,-0.10671853591879483514,0.073505947527277515352,0.10524465629064236327,0.098978621772914290866,0.1428638679352601526,-0.007912130839509800076],[-0.755120465258354856,-1.7238989284471688546,-1.6538923820335600379,2.0471245945044915793,-0.57351368935018787187,-1.222406031088757894,-1.2961379775532957392,0.66485717209253503146,0.027370067050677331782,0.21054603968499563393],[2.0343535816248237147,0.33562953740282586157,-0.42825323868011294648,-2.5072524404011975463,-0.26919547296005669201,0.62752492885057076233,-0.16158182046139132892,-0.22367853646109667198,-0.82518406351324891101,0.11336141663162481452],[0.51730138436926242917,0.11304189712785341071,-0.047412083258119581963,0.45660927170827048105,-0.26896010527340541429,1.3026924350269559749,-0.60371505631623190169,1.2596691186684922936,-0.41809873387871737682,-0.072923818026420367255],[0.58635947171035984748,-0.15879822271506360831,-0.040694077286644106395,-0.97548803872086797817,1.2009690009127382826,1.0869989849449628316,-0.3185783820724945592,-1.8137429492431995648,-0.8722777573222401104,-0.16520814459267130214],[-0.70266414052749803787,0.9574121285645278423,-0.94729927589585849468,-0.28224981146191646664,-0.14398138695462697756,-0.61162380331148646917,0.32601346272075665267,-0.11794700810447451833,0.2033944761077132457,-0.12300534273502794491] - ]) - - LW2_1 = np.array([ - 1.5598411501307831717,3.0518213473977828798,1.9692286411650965494,0.68408854039050825957,1.1269238219932133926,-2.6312197636288825464,-0.74334398169426096903,-1.6728462595975237548,-4.5277731890756109934,2.0394142452183401382,-1.4677828109204844598,2.8071790565928202987,2.6558903870346637355,-4.1710887662639057893,2.8206050038847387817,2.1170071154749972031,0.54806101255802652794,-1.5114297743564342191,0.11532237677727565084,-1.9704061919624336063,0.81301711728032177717,0.9545086499966127791,0.45826792051469911193,1.2195869429760046732,-4.2594350561452678505,-0.64174811370623130458,0.86184766619713892855,1.6746818427659309059,-0.62475945690155054724,-1.8575118942617874218 - ]) - + b1 = np.array( + [ + -0.24993894877835426405, + -1.4074489845198050464, + 0.36936327175133853995, + 0.057939601944852772708, + 1.9795132968497040071, + 0.55881187347895833195, + -0.036728278753663301526, + 4.9086085622615716062, + -0.53564449041321005041, + -0.18204020322168745771, + 0.50494484119436178204, + 1.094128385226589284, + 1.0288635669728540822, + -1.9317279818184966977, + -2.6458995887990104379, + -0.011974455894031446265, + -0.60094092258880849045, + 0.78813455341049654113, + -1.8733003300173409755, + 1.2843446263928828266, + 4.9496606441232806617, + 0.62525376096305751439, + 0.070635993485867340502, + 0.5532806896103561467, + -0.31318558029335957782, + -3.1756685576164027651, + 0.36484003106961571117, + 3.1054833189228001622, + 0.17485515791777112016, + -0.50672241960890174184, + ] + ) + + b2 = -1.6781467240672391927 + + IW1_1 = np.array( + [ + [ + 0.20429212671712271288, + -0.23929451587367925325, + 0.52513511712378968532, + 0.018053885729492239604, + -0.80801055178586178585, + -0.21736821316205012788, + 0.37621880824590758774, + 1.232055133661766444, + 0.020678617117498854228, + -0.091703286437006023557, + ], + [ + -0.25140742042609348639, + -0.051614109013430900519, + -1.922102052733124733, + -1.4836259016837574087, + -0.17618569277694015596, + -1.2479305185798976741, + 0.62363904950321336074, + -2.1263337727538540456, + 2.1774443421359457318, + 0.22680842193787495442, + ], + [ + -2.0948685890899865214, + 6.6479204104320945845, + -2.4531560128359113371, + -1.628820551854999632, + 0.10321980810974851206, + -0.92445544707524074379, + -0.043995541307992262758, + 0.82180593331734164142, + 0.10451212943746462924, + 0.061864274838177454874, + ], + [ + -2.3406951576394057213, + 2.79457405210700216, + -1.5604841346364726196, + 1.4724361597151189862, + -1.745867955251196868, + 2.0516938191549161097, + 0.21999967207360407451, + 2.7164013342896309311, + -0.026258728254549633385, + -0.082634303788204799268, + ], + [ + -3.2384231961266087829, + -0.036460130642652736899, + 0.4499641488520816357, + 0.75187984378050209955, + 0.14240305072267772646, + -1.6485410398905828711, + 3.2596268731460411594, + 0.062977562217264734801, + -0.47746525602004052935, + -0.55688340969520555568, + ], + [ + -2.5007319774223777387, + 8.4669625066243732192, + -2.7713936609354443696, + -2.7975063803821229591, + 0.45738311220126831591, + -0.95341514288248252473, + -0.32812922778532915835, + 0.76634251943203512969, + 0.083352056618799227894, + 0.058925973000700813953, + ], + [ + -2.2998829900219668332, + 1.9538472165240738931, + -1.1103233988276735023, + 2.0833605325066644198, + -1.3751503929572219675, + 0.21628693521636080388, + 0.064363803798405505585, + 0.83514789931470012618, + 0.24819706017159959277, + 0.11555601551331276533, + ], + [ + 1.7300175815344223107, + 4.4985529991422854579, + 3.0253256260073895234, + -0.13790006035207547086, + -0.30868194407806803792, + 1.4799802014883147727, + 1.4969102401839742278, + -1.1688598485649086545, + -0.24703610773163817149, + 1.0337548160538814201, + ], + [ + -1.8189568107143478937, + -0.29570394369439462201, + -0.37434080879778386386, + 0.61742443446832129261, + -1.1201829886568677175, + -0.13857511824780135989, + 0.13724278170002393584, + 0.52248659179980494471, + 0.21718313213769810388, + -0.80372204521904166974, + ], + [ + -0.42628541353061261132, + -2.6202053651174717075, + 0.58337005579702916336, + 1.6654239333180154148, + 0.0012463794134951048428, + 1.1175040820400004016, + -0.47091949391429771543, + -0.54849572710700456035, + -0.096026639619788370372, + -0.073242950095284531375, + ], + [ + 1.2786808820056998481, + -1.8976601077085668567, + 0.81753843265278081098, + 0.51954848490749083734, + -0.60177841904341244916, + -0.4149984470142603632, + 0.15397615165803718584, + 0.88879895245800311088, + 0.64361136826190123994, + -0.17661415007775732589, + ], + [ + -1.2552067236197173017, + 1.362118408866962449, + -0.28523011645022011695, + 1.6624777633937539711, + -1.0304922149380943974, + 2.2232047216647452537, + -0.036659332674587298551, + 2.6885602330418900685, + -0.10647187809918032264, + -2.2946037281607667424, + ], + [ + 0.030665279023735930036, + 0.6118234827556265909, + 0.68251307161473995233, + 0.13956107643009760255, + -0.095597928867966877609, + 0.66979022075694549798, + 0.30953150420749736549, + 0.29305398375197100336, + 0.31863609417702787319, + 1.2720067652372168965, + ], + [ + 2.1992040524547888936, + 1.2442625481112548069, + -0.40544391572007087987, + -0.6850842667282354137, + -1.2526495125817032061, + 2.3349544527802623683, + -2.6593743397832989572, + -0.23502061687655856348, + 0.44588273520362925462, + 0.43791538694513199026, + ], + [ + -0.031609071316792067274, + 2.6870579605267987944, + -0.57613856804941165901, + 1.3520150660819514332, + 0.94664815867069462829, + 0.40252975972644200464, + 0.99037137128783025997, + -1.2027184902192968874, + 0.42636650616348920062, + -0.5363227337031130082, + ], + [ + -2.4412882781341065375, + 2.0562626817202791507, + -0.11676889048254589232, + 1.483851502405851841, + -1.5664224225134093516, + 0.54740263684407519662, + 0.58062495794547575034, + 0.25955204327966802103, + 0.32612260415461485907, + 0.5265289845241252209, + ], + [ + 1.6651174309696916698, + -1.3558068527375624068, + 0.53431590530365369318, + -0.93337382036218830006, + 0.70092369236857221537, + -0.55548298695363074184, + -0.22034441826216052962, + 0.497240042865797649, + -1.062509066100663091, + 0.06719322716872244694, + ], + [ + 1.9103678430029404911, + -0.56292194703989906213, + 1.6128272967996970522, + -1.0945581490595759355, + 0.42568525321225070268, + 0.86987372825166409118, + 0.14651521194644431811, + 0.75830074980901529536, + 0.13378653384709510155, + -1.0524110757753599721, + ], + [ + 0.24393124959427145426, + 0.66550875598288949941, + -0.99336797727588455054, + -0.31751133139054182886, + 1.71244615335321404, + -0.075861023505085348195, + -1.1326896565571482611, + -3.0962909788777821518, + 0.065484927038083923234, + 0.11830800536345571772, + ], + [ + 0.12112762034455684668, + -0.035720631357465268407, + 1.3167414294806587538, + 1.9264098443537411853, + 0.10783093357860036587, + 1.1780338927376514668, + -0.86401974053534869036, + 2.4215781455585081439, + -2.0795438163786532648, + -0.16795881941649917768, + ], + [ + -2.7709792619767705801, + -0.8838005170040182934, + -2.1374211896350692186, + -1.7521960724117786601, + -0.47276373416214906298, + 0.41228023478486430786, + 0.55621794697886772774, + -1.1460927235255020662, + -2.5726572284104567423, + 2.2988228659561000811, + ], + [ + 1.9307340569110567063, + -0.87067333088204623692, + 2.4755164582737925194, + -1.5597052107804496579, + 0.35301125023098983702, + 0.76379761307882609866, + 0.63147432586900642537, + 0.46509193637462720172, + 0.029681156516113610389, + 0.99583072929614113722, + ], + [ + 0.8505627619069540124, + -0.064812435223547404384, + -1.9826423242902309063, + 0.92885683837492416526, + 0.19079267865907645341, + -0.39196841517068103933, + -1.3496321939633635356, + 0.20298997001561597253, + 0.41059823356024632846, + -0.76108514213741118581, + ], + [ + -0.15816327613094746662, + 0.10165328534463963228, + 0.054254257449186257811, + 0.25222159559077667046, + -0.11281116280261438423, + 0.163325175062264627, + -0.024917340809610600411, + -0.04357303399881133632, + 0.49597935997874564862, + 0.030605228918109721875, + ], + [ + -3.7966853934195969877, + 0.55337541031306280992, + -1.2493134975541688725, + 2.0659996886177713904, + -1.4283801807842264608, + 0.21525599827384364615, + -0.27875482452432126523, + 0.92382506475522796485, + 0.10331282852244655368, + 1.0183891325938791983, + ], + [ + -3.7756361253104429032, + 1.5450965113216938995, + -2.7578004461965961447, + 1.0475146399151209486, + -0.22554138061419520822, + 0.84598299906175733476, + -0.72610682566849149566, + -0.50127606269020197338, + 0.40470106223467267048, + 0.15097301336574053821, + ], + [ + -1.5023096688029380363, + 1.8573453665274974878, + 0.033950120499802428908, + -1.1174857501964106099, + -0.8658956300848906773, + 0.091749433509896713423, + 1.131179861043504209, + -0.21896040529280549891, + -0.12549615265539451614, + -0.0028106342157373414084, + ], + [ + 0.62872286041439628956, + -2.3582833602645427717, + 0.52570820625175307406, + -1.9270676810051770023, + 0.028903030587852436561, + -0.20484679809130093564, + -0.55014712285758127219, + 0.060909760786119392095, + -0.61654337536966963285, + 0.87004726613835270399, + ], + [ + 0.30532518950721893036, + 2.2736608243276630326, + -0.7597545997145127572, + -0.39484243846392819144, + -0.22044175484458622405, + -0.94205897026127649596, + 0.48138588376933011403, + 0.53689455618537729187, + 0.043574229586201475295, + 0.14700034203289971679, + ], + [ + 0.11578564706480209967, + 0.26902246618783304255, + 1.0900765353053587514, + -2.1939721865945220891, + 1.1164357708114887036, + 0.088901040767284625344, + 0.37454569909419860307, + -1.1150556783202594247, + -0.84971098524787513906, + 0.52274040275075872586, + ], + ] + ) + + LW2_1 = np.array( + [ + 2.8413716103689234949, + -1.0675463574340400275, + 3.5231118744746474647, + 0.43029223335496008529, + 1.1229946783876043614, + -1.8370101582764875037, + -3.301116409217189851, + -0.23926761465244583693, + -1.1156262859383700992, + 3.1828966653852175384, + -2.3750467874575704741, + 0.51071812129907456779, + -0.76296135826069411134, + 1.1266229329590433661, + 1.7395385550153283916, + 1.9079642339677311824, + 1.2272482348112778716, + -1.986838383213631154, + -0.82532863922956123393, + -1.1055610930195920449, + 0.23892726661389115939, + -1.5951031747984814047, + -0.83407375315665510662, + 5.9403716241802291265, + -0.98540271551724389898, + -0.76348625484333032531, + -1.2028627909457105805, + 1.9279886099427794299, + 1.5325813028922228298, + -1.1097828506562146256, + ] + ) + # Forward pass Q = x1.shape[1] xp1 = mapminmax_apply(x1, x1_step1) a1 = tansig(np.outer(b1, np.ones(Q)) + IW1_1 @ xp1) a2 = tansig(b2 + LW2_1 @ a1) y1 = mapminmax_reverse(a2, y1_step1) - + # Denormalize output - minOutput = 2032.1701 - maxOutput = 3961.0986 + minOutput = 212.7656 + maxOutput = 1886.9746 y1 = y1.T * (maxOutput - minOutput) + minOutput - - return y1 \ No newline at end of file + + return y1 From e9f08de85dd85b0da38ce3ae94a0a1344045f446 Mon Sep 17 00:00:00 2001 From: Christopher Bay Date: Fri, 12 Dec 2025 12:20:48 -0700 Subject: [PATCH 07/11] integrate other surrogate DEL models into FLORIS component --- ard/farm_aero/floris.py | 72 ++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 12 deletions(-) diff --git a/ard/farm_aero/floris.py b/ard/farm_aero/floris.py index 7e480485..98e77e95 100644 --- a/ard/farm_aero/floris.py +++ b/ard/farm_aero/floris.py @@ -7,7 +7,12 @@ import floris.turbine_library.turbine_utilities import ard.farm_aero.templates as templates -from ard.farm_loads.surrogate_load_functions import ANN_DEL_TowerBase +from ard.farm_loads.surrogate_load_functions import ( + ANN_DEL_BladeRoot, + ANN_DEL_Shaft, + ANN_DEL_TowerBase, + ANN_DEL_YawBearings, +) def create_FLORIS_turbine_from_windIO( @@ -276,7 +281,7 @@ def get_thrust_turbines(self): else: return thrust_turbines.T - def get_tower_base_load(self): + def get_DELs(self): SATI = self.fmodel.get_turbine_SATI() * 100 SAWS = self.fmodel.get_turbine_SAWS() turbine_powers_percent = self.fmodel.get_turbine_powers_percent().flatten() @@ -297,18 +302,40 @@ def get_tower_base_load(self): axis=1, ) - # Make predictions using ANN surrogate + # Make predictions using ANN surrogates + del_bladeroot_ann = ANN_DEL_BladeRoot(input_data) + del_shaft_ann = ANN_DEL_Shaft(input_data) del_towerbase_ann = ANN_DEL_TowerBase(input_data) + del_yawbearings_ann = ANN_DEL_YawBearings(input_data) # Weight predictions by frequency of wind conditions - weighted_observed_pred = np.zeros_like (del_towerbase_ann) + weighted_del_bladeroot = np.zeros_like(del_towerbase_ann) + weighted_del_shaft = np.zeros_like(del_towerbase_ann) + weighted_del_towerbase = np.zeros_like(del_towerbase_ann) + weighted_del_yawbearings = np.zeros_like(del_towerbase_ann) n_turbs = self.N_turbines for i, f in enumerate(self.wind_query.freq_table.flatten()): - weighted_observed_pred[i * n_turbs: i * n_turbs + n_turbs] = del_towerbase_ann[i * n_turbs: i * n_turbs + n_turbs] * f + weighted_del_bladeroot[i * n_turbs : i * n_turbs + n_turbs] = ( + del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f + ) + weighted_del_shaft[i * n_turbs : i * n_turbs + n_turbs] = ( + del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f + ) + weighted_del_towerbase[i * n_turbs : i * n_turbs + n_turbs] = ( + del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f + ) + weighted_del_yawbearings[i * n_turbs : i * n_turbs + n_turbs] = ( + del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f + ) - return np.sum(weighted_observed_pred) + return ( + np.sum(weighted_del_bladeroot), + np.sum(weighted_del_shaft), + np.sum(weighted_del_towerbase), + np.sum(weighted_del_yawbearings), + ) def dump_floris_yamlfile(self, dir_output=None): """ @@ -519,9 +546,9 @@ def setup_partials(self): FLORISFarmComponent.setup_partials(self) -class FLORISTowerBaseLoad(FLORISAEP): +class FLORISSurrogateDELs(FLORISAEP): """ - Component class for computing surrogate tower base loads using FLORIS. + Component class for computing surrogate DELs using FLORIS. """ def initialize(self): @@ -531,10 +558,28 @@ def setup(self): super().setup() # run super class script first! self.add_output( - "tower_base_load", + "blade_root_del", + 0.0, + units="kN*m", + desc="frequency weighted sum of blade root DEL across all wind conditions", + ) + self.add_output( + "shaft_del", 0.0, units="kN*m", - desc="maximum tower base load across all wind conditions", + desc="frequency weighted sum of shaft DEL across all wind conditions", + ) + self.add_output( + "tower_base_del", + 0.0, + units="kN*m", + desc="frequency weighted sum of tower base DEL across all wind conditions", + ) + self.add_output( + "yaw_bearings_del", + 0.0, + units="kN*m", + desc="frequency weighted sum of yaw bearings DELs across all wind conditions", ) def setup_partials(self): @@ -542,9 +587,12 @@ def setup_partials(self): def compute(self, inputs, outputs): super().compute(inputs, outputs) - outputs["tower_base_load"] = FLORISFarmComponent.get_tower_base_load(self) + DEL_outputs = FLORISFarmComponent.get_DELs(self) + outputs["blade_root_load"] = DEL_outputs[0] + outputs["shaft_load"] = DEL_outputs[1] + outputs["tower_base_load"] = DEL_outputs[2] + outputs["yaw_bearings_load"] = DEL_outputs[3] outputs["AEP_farm"] = FLORISFarmComponent.get_AEP_farm(self) def setup_partials(self): FLORISFarmComponent.setup_partials(self) - From d1f61a5fefea1c38103fefd66f04866f5438295f Mon Sep 17 00:00:00 2001 From: Christopher Bay Date: Fri, 12 Dec 2025 12:21:06 -0700 Subject: [PATCH 08/11] update loads example to include other DELs info --- .../inputs/ard_system.yaml | 8 ++++---- .../optimization_demo.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml b/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml index 150e34eb..44d8654c 100644 --- a/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml +++ b/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml @@ -13,7 +13,7 @@ modeling_options: &modeling_options time_limit: 60 mip_gap: 0.02 model_options: - topology: radial # radial, branched + topology: branched # radial, branched feeder_route: segmented feeder_limit: unlimited offshore: false @@ -43,8 +43,8 @@ system: aepFLORIS: type: component module: ard.farm_aero.floris - object: FLORISTowerBaseLoad - promotes: ["x_turbines", "y_turbines", "AEP_farm", "tower_base_load"] + object: FLORISSurrogateDELs + promotes: ["x_turbines", "y_turbines", "AEP_farm", "blade_root_DEL", "shaft_DEL", "tower_base_DEL", "yaw_bearings_DEL"] kwargs: modeling_options: *modeling_options data_path: @@ -146,7 +146,7 @@ analysis_options: units: km lower: 0.552 objectives: - aepFLORIS.tower_base_load: + aepFLORIS.tower_base_DEL: scaler: 1.0 recorder: filepath: cases.sql diff --git a/examples/x08_layout_with_surrogate_loads/optimization_demo.py b/examples/x08_layout_with_surrogate_loads/optimization_demo.py index 994fb9b4..bb9bd3c3 100644 --- a/examples/x08_layout_with_surrogate_loads/optimization_demo.py +++ b/examples/x08_layout_with_surrogate_loads/optimization_demo.py @@ -41,7 +41,10 @@ "turbine_spacing": float( np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) ), - "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), + "blade_root_DEL": float(prob.get_val("aepFLORIS.blade_root_DEL", units="kN*m")[0]), + "shaft_DEL": float(prob.get_val("aepFLORIS.shaft_DEL", units="kN*m")[0]), + "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_DEL", units="kN*m")[0]), + "yaw_bearings_DEL": float(prob.get_val("aepFLORIS.yaw_bearings_DEL", units="kN*m")[0]), } print("\n\nRESULTS:\n") @@ -67,7 +70,10 @@ "turbine_spacing": float( np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) ), - "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), + "blade_root_DEL": float(prob.get_val("aepFLORIS.blade_root_DEL", units="kN*m")[0]), + "shaft_DEL": float(prob.get_val("aepFLORIS.shaft_DEL", units="kN*m")[0]), + "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_DEL", units="kN*m")[0]), + "yaw_bearings_DEL": float(prob.get_val("aepFLORIS.yaw_bearings_DEL", units="kN*m")[0]), } # clean up the recorder From 3094f026c71e05ed7374d00c670a9fbbdcf2d11b Mon Sep 17 00:00:00 2001 From: Cory Frontin Date: Mon, 15 Dec 2025 22:15:00 -0700 Subject: [PATCH 09/11] push updates back into loads_surrogates --- ard/farm_aero/floris.py | 8 ++++---- .../inputs/ard_system.yaml | 2 +- .../inputs/windio.yaml | 2 +- .../optimization_demo.py | 16 ++++++++-------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ard/farm_aero/floris.py b/ard/farm_aero/floris.py index 6a1862f3..4a61712d 100644 --- a/ard/farm_aero/floris.py +++ b/ard/farm_aero/floris.py @@ -568,25 +568,25 @@ def setup(self): super().setup() # run super class script first! self.add_output( - "blade_root_del", + "blade_root_load", 0.0, units="kN*m", desc="frequency weighted sum of blade root DEL across all wind conditions", ) self.add_output( - "shaft_del", + "shaft_load", 0.0, units="kN*m", desc="frequency weighted sum of shaft DEL across all wind conditions", ) self.add_output( - "tower_base_del", + "tower_base_load", 0.0, units="kN*m", desc="frequency weighted sum of tower base DEL across all wind conditions", ) self.add_output( - "yaw_bearings_del", + "yaw_bearings_load", 0.0, units="kN*m", desc="frequency weighted sum of yaw bearings DELs across all wind conditions", diff --git a/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml b/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml index 44d8654c..6c71b8a6 100644 --- a/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml +++ b/examples/x08_layout_with_surrogate_loads/inputs/ard_system.yaml @@ -44,7 +44,7 @@ system: type: component module: ard.farm_aero.floris object: FLORISSurrogateDELs - promotes: ["x_turbines", "y_turbines", "AEP_farm", "blade_root_DEL", "shaft_DEL", "tower_base_DEL", "yaw_bearings_DEL"] + promotes: ["x_turbines", "y_turbines", "AEP_farm"] kwargs: modeling_options: *modeling_options data_path: diff --git a/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml b/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml index c287c964..1f208da7 100644 --- a/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml +++ b/examples/x08_layout_with_surrogate_loads/inputs/windio.yaml @@ -41,4 +41,4 @@ wind_farm: - electrical_substation: coordinates: x: [100.0] - y: [100.0] \ No newline at end of file + y: [ 0.0] \ No newline at end of file diff --git a/examples/x08_layout_with_surrogate_loads/optimization_demo.py b/examples/x08_layout_with_surrogate_loads/optimization_demo.py index bb9bd3c3..2264c60d 100644 --- a/examples/x08_layout_with_surrogate_loads/optimization_demo.py +++ b/examples/x08_layout_with_surrogate_loads/optimization_demo.py @@ -41,10 +41,10 @@ "turbine_spacing": float( np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) ), - "blade_root_DEL": float(prob.get_val("aepFLORIS.blade_root_DEL", units="kN*m")[0]), - "shaft_DEL": float(prob.get_val("aepFLORIS.shaft_DEL", units="kN*m")[0]), - "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_DEL", units="kN*m")[0]), - "yaw_bearings_DEL": float(prob.get_val("aepFLORIS.yaw_bearings_DEL", units="kN*m")[0]), + "blade_root_load": float(prob.get_val("aepFLORIS.blade_root_load", units="kN*m")[0]), + "shaft_load": float(prob.get_val("aepFLORIS.shaft_load", units="kN*m")[0]), + "tower_base_load": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), + "yaw_bearings_load": float(prob.get_val("aepFLORIS.yaw_bearings_load", units="kN*m")[0]), } print("\n\nRESULTS:\n") @@ -70,10 +70,10 @@ "turbine_spacing": float( np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) ), - "blade_root_DEL": float(prob.get_val("aepFLORIS.blade_root_DEL", units="kN*m")[0]), - "shaft_DEL": float(prob.get_val("aepFLORIS.shaft_DEL", units="kN*m")[0]), - "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_DEL", units="kN*m")[0]), - "yaw_bearings_DEL": float(prob.get_val("aepFLORIS.yaw_bearings_DEL", units="kN*m")[0]), + "blade_root_load": float(prob.get_val("aepFLORIS.blade_root_load", units="kN*m")[0]), + "shaft_load": float(prob.get_val("aepFLORIS.shaft_load", units="kN*m")[0]), + "tower_base_load": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), + "yaw_bearings_load": float(prob.get_val("aepFLORIS.yaw_bearings_load", units="kN*m")[0]), } # clean up the recorder From 57061f810308131ea0cc27493bffb7dc20e6849f Mon Sep 17 00:00:00 2001 From: Cory Frontin Date: Wed, 31 Dec 2025 14:04:56 -0700 Subject: [PATCH 10/11] pull out fix from x_nsga branch --- ard/farm_aero/floris.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ard/farm_aero/floris.py b/ard/farm_aero/floris.py index 4a61712d..15f1cb53 100644 --- a/ard/farm_aero/floris.py +++ b/ard/farm_aero/floris.py @@ -321,16 +321,16 @@ def get_DELs(self): for i, f in enumerate(self.wind_query.freq_table.flatten()): weighted_del_bladeroot[i * n_turbs : i * n_turbs + n_turbs] = ( - del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f + del_bladeroot_ann[i * n_turbs : i * n_turbs + n_turbs] * f ) weighted_del_shaft[i * n_turbs : i * n_turbs + n_turbs] = ( - del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f + del_shaft_ann[i * n_turbs : i * n_turbs + n_turbs] * f ) weighted_del_towerbase[i * n_turbs : i * n_turbs + n_turbs] = ( del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f ) weighted_del_yawbearings[i * n_turbs : i * n_turbs + n_turbs] = ( - del_towerbase_ann[i * n_turbs : i * n_turbs + n_turbs] * f + del_yawbearings_ann[i * n_turbs : i * n_turbs + n_turbs] * f ) return ( @@ -568,25 +568,25 @@ def setup(self): super().setup() # run super class script first! self.add_output( - "blade_root_load", + "blade_root_DEL", 0.0, units="kN*m", desc="frequency weighted sum of blade root DEL across all wind conditions", ) self.add_output( - "shaft_load", + "shaft_DEL", 0.0, units="kN*m", desc="frequency weighted sum of shaft DEL across all wind conditions", ) self.add_output( - "tower_base_load", + "tower_base_DEL", 0.0, units="kN*m", desc="frequency weighted sum of tower base DEL across all wind conditions", ) self.add_output( - "yaw_bearings_load", + "yaw_bearings_DEL", 0.0, units="kN*m", desc="frequency weighted sum of yaw bearings DELs across all wind conditions", @@ -598,10 +598,10 @@ def setup_partials(self): def compute(self, inputs, outputs): super().compute(inputs, outputs) DEL_outputs = FLORISFarmComponent.get_DELs(self) - outputs["blade_root_load"] = DEL_outputs[0] - outputs["shaft_load"] = DEL_outputs[1] - outputs["tower_base_load"] = DEL_outputs[2] - outputs["yaw_bearings_load"] = DEL_outputs[3] + outputs["blade_root_DEL"] = DEL_outputs[0] + outputs["shaft_DEL"] = DEL_outputs[1] + outputs["tower_base_DEL"] = DEL_outputs[2] + outputs["yaw_bearings_DEL"] = DEL_outputs[3] outputs["AEP_farm"] = FLORISFarmComponent.get_AEP_farm(self) def setup_partials(self): From 63bd4976772dfa1dd8fa1524fcac6c5b722e71f9 Mon Sep 17 00:00:00 2001 From: Cory Frontin Date: Wed, 31 Dec 2025 14:15:17 -0700 Subject: [PATCH 11/11] update variable names --- .../optimization_demo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/x08_layout_with_surrogate_loads/optimization_demo.py b/examples/x08_layout_with_surrogate_loads/optimization_demo.py index 2264c60d..bb9bd3c3 100644 --- a/examples/x08_layout_with_surrogate_loads/optimization_demo.py +++ b/examples/x08_layout_with_surrogate_loads/optimization_demo.py @@ -41,10 +41,10 @@ "turbine_spacing": float( np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) ), - "blade_root_load": float(prob.get_val("aepFLORIS.blade_root_load", units="kN*m")[0]), - "shaft_load": float(prob.get_val("aepFLORIS.shaft_load", units="kN*m")[0]), - "tower_base_load": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), - "yaw_bearings_load": float(prob.get_val("aepFLORIS.yaw_bearings_load", units="kN*m")[0]), + "blade_root_DEL": float(prob.get_val("aepFLORIS.blade_root_DEL", units="kN*m")[0]), + "shaft_DEL": float(prob.get_val("aepFLORIS.shaft_DEL", units="kN*m")[0]), + "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_DEL", units="kN*m")[0]), + "yaw_bearings_DEL": float(prob.get_val("aepFLORIS.yaw_bearings_DEL", units="kN*m")[0]), } print("\n\nRESULTS:\n") @@ -70,10 +70,10 @@ "turbine_spacing": float( np.min(prob.get_val("spacing_constraint.turbine_spacing", units="km")) ), - "blade_root_load": float(prob.get_val("aepFLORIS.blade_root_load", units="kN*m")[0]), - "shaft_load": float(prob.get_val("aepFLORIS.shaft_load", units="kN*m")[0]), - "tower_base_load": float(prob.get_val("aepFLORIS.tower_base_load", units="kN*m")[0]), - "yaw_bearings_load": float(prob.get_val("aepFLORIS.yaw_bearings_load", units="kN*m")[0]), + "blade_root_DEL": float(prob.get_val("aepFLORIS.blade_root_DEL", units="kN*m")[0]), + "shaft_DEL": float(prob.get_val("aepFLORIS.shaft_DEL", units="kN*m")[0]), + "tower_base_DEL": float(prob.get_val("aepFLORIS.tower_base_DEL", units="kN*m")[0]), + "yaw_bearings_DEL": float(prob.get_val("aepFLORIS.yaw_bearings_DEL", units="kN*m")[0]), } # clean up the recorder