I have now managed to create the airfoils and the rectangle that will represent the flow domain. I am struggling with how to actually extrude the airfoils through the box that I have created.
Any advice on how I could continue, how should I handle the fact that they are not a sketch on the box? Do I have to use Shapebinders somehow?
Code: Select all
import FreeCAD
from FreeCAD import Base, Vector
import Part
from math import pi, sin, cos
import numpy as np
DOC = FreeCAD.activeDocument()
DOC_NAME = "Pippo"
def clear_doc():
"""
Clear the active document deleting all the objects
"""
for obj in DOC.Objects:
DOC.removeObject(obj.Name)
def setview():
"""Rearrange View"""
FreeCAD.Gui.SendMsgToActiveView("ViewFit")
FreeCAD.Gui.activeDocument().activeView().viewAxometric()
if DOC is None:
FreeCAD.newDocument(DOC_NAME)
FreeCAD.setActiveDocument(DOC_NAME)
DOC = FreeCAD.activeDocument()
else:
clear_doc()
# EPS= tolerance to use to cut the parts
EPS = 0.10
EPS_C = EPS * -0.5
Scale_factor = 14
x_l = [0.0, 0.005025126442071894, 0.010050252331580046, 0.01507537811410561, 0.020100503835442318, 0.02512562951427127, 0.030150755160656205, 0.035175880780869924, 0.04020100637919822, 0.04522613195876145, 0.05025125752194019, 0.05527638307061694, 0.06030150860632311, 0.06532663413033356, 0.07035175964372974, 0.07537688514744387, 0.08040201064229034, 0.08542713612898889, 0.09045226160818201, 0.09547738708044819, 0.10050251256261035, 0.10552763818867451, 0.11055276381467101, 0.11557788944060485, 0.12060301506648068, 0.12562814069230285, 0.1306532663180755, 0.13567839194380235, 0.14070351756948704, 0.14572864319513296, 0.15075376882074332, 0.15577889444632118, 0.16080402007186942, 0.16582914569739085, 0.17085427132288805, 0.17587939694836363, 0.18090452257381992, 0.18592964819925928, 0.19095477382468393, 0.19597989945009606, 0.2010050250754976, 0.20603015070089067, 0.2110552763262771, 0.21608040195165878, 0.2211055275770375, 0.22613065320241493, 0.23115577882779276, 0.2361809044531726, 0.24120603007855607, 0.24623115570394463, 0.25125628132933975, 0.2562814069547429, 0.26130653258015535, 0.2663316582055785, 0.2713567838310138, 0.2763819094564623, 0.28140703508192527, 0.28643216070740407, 0.29145728633289963, 0.29648241195841324, 0.301507537583946, 0.3065326632094989, 0.31155778883507307, 0.3165829144606694, 0.321608040086289, 0.32663316571193285, 0.3316582913376018, 0.33668341696329684, 0.3417085425890188, 0.34673366821476864, 0.35175879384054715, 0.35678391946635507, 0.3618090450921934, 0.36683417071806285, 0.3718592963439642, 0.37688442196989813, 0.3819095475958655, 0.3869346732218669, 0.39195979884790316, 0.3969849244739749, 0.4020100501000827, 0.4070351757262274, 0.41206030135240956, 0.4170854269786298, 0.4221105526048888, 0.42713567823118703, 0.43216080385752514, 0.4371859294839038, 0.44221105511032344, 0.4472361807367846, 0.452261306363288, 0.457286431989834, 0.46231155761642323, 0.46733668324305616, 0.4723618088697332, 0.47738693449645503, 0.48241206012322196, 0.4874371857500346, 0.49246231137689334, 0.4974874370037986, 0.502512562630751, 0.5075376882577507, 0.5125628138847985, 0.5175879395118946, 0.5226130651390395, 0.5276381907662334, 0.532663316393477, 0.5376884420207707, 0.5427135676481147, 0.5477386932755096, 0.5527638189029558, 0.5577889445304534, 0.562814070158003, 0.567839195785605, 0.5728643214132598, 0.5778894470409678, 0.582914572668729, 0.5879396982965444, 0.5929648239244139, 0.597989949552338, 0.6030150751803172, 0.6080402008083514, 0.6130653264364416, 0.6180904520645878, 0.6231155776927905, 0.6281407033210499, 0.6331658289493663, 0.6381909545777404, 0.6432160802061724, 0.6482412058346626, 0.6532663314632113, 0.658291457091819, 0.6633165827204861, 0.6683417083492129, 0.6733668339779998, 0.6783919596068472, 0.6834170852357552, 0.6884422108647246, 0.6934673364937555, 0.6984924621228483, 0.7035175877520036, 0.7085427133812214, 0.7135678390105026, 0.7185929646398472, 0.7236180902692557, 0.7286432158987287, 0.7336683415282663, 0.7386934671578691, 0.7437185927875376, 0.7487437184172722, 0.7537688440470731, 0.7587939696769409, 0.7638190953068761, 0.7688442209368791, 0.7738693465669504, 0.7788944721970903, 0.7839195978272996, 0.7889447234575784, 0.7939698490879274, 0.7989949747183471, 0.8040201003488381, 0.8090452259794007, 0.8140703516100354, 0.8190954772407429, 0.8241206028715238, 0.8291457285023784, 0.8341708541333075, 0.8391959797643115, 0.844221105395391, 0.8492462310265466, 0.854271356657779, 0.8592964822890887, 0.8643216079204763, 0.8693467335519425, 0.8743718591834879, 0.8793969848151133, 0.8844221104468191, 0.8894472360786061, 0.894472361710475, 0.8994974873424265, 0.9045226129744615, 0.9095477386065803, 0.9145728642387839, 0.9195979898710731, 0.9246231155034486, 0.9296482411359112, 0.9346733667684616, 0.9396984924011006, 0.9447236180338292, 0.9497487436666482, 0.9547738692995582, 0.9597989949325604, 0.9648241205656554, 0.9698492461988443, 0.9748743718321279, 0.9798994974655072, 0.9849246230989831, 0.9899497487325566, 0.9949748743662284, 1.0]
y_l = [0.0, -0.04284981654890956, -0.05977218671601489, -0.07239852533034395, -0.08278396852776697, -0.0917248260471896, -0.0996297064290181, -0.10674151700621234, -0.11321867402161037, -0.1191713426550491, -0.1246798469808652, -0.1298049263246729, -0.1345938601257772, -0.13908432982435873, -0.14330696281720842, -0.1472870697590824, -0.15104586740721035, -0.15460136179236456, -0.15796900037687908, -0.1611621630233855, -0.1641925379479105, -0.16707041396588215, -0.1698049107505826, -0.17240416244800713, -0.1748754657000664, -0.17722540016558633, -0.17945992753674295, -0.18158447356262794, -0.18360399651390114, -0.18552304473131445, -0.18734580531287678, -0.1890761455523981, -0.1907176484063397, -0.1922736430082731, -0.19374723105079877, -0.19514130969904692, -0.19645859157731638, -0.1977016222732263, -0.19887279572615402, -0.19997436780436256, -0.2010084683247764, -0.20197711172832558, -0.20288220659020875, -0.20372556411681536, -0.20450890575823194, -0.20523387004630822, -0.2059020187524541, -0.2065148424460964, -0.20707376552358786, -0.20758015076795297, -0.20803530349188334, -0.20844047530961277, -0.20879686757751245, -0.2091056345382892, -0.20936788619940852, -0.20958469097269736, -0.20975707809890556, -0.2098860398782581, -0.2099725337256421, -0.21001748406699108, -0.21002178409160954, -0.2099862973735936, -0.20991185937410362, -0.20979927883501978, -0.20964933907342487, -0.20946279918540936, -0.20924039516683982, -0.20898284095798836, -0.2086908294182492, -0.20836503323658007, -0.20800610578277062, -0.20761468190417467, -0.20719137867211507, -0.206736796081793, -0.20625151770919484, -0.20573611132817973, -0.20519112949066182, -0.2046171100725472, -0.20401457678786503, -0.20338403967332885, -0.20272599554538026, -0.20204092843160043, -0.20132930997822712, -0.20059159983537125, -0.19982824602141144, -0.19903968526792104, -0.19822634334638814, -0.1973886353778858, -0.19652696612677087, -0.19564173027940435, -0.1947333127088179, -0.1938020887261818, -0.19284842431987156, -0.1918726763828718, -0.19087519292920427, -0.18985631330002234, -0.18881636835996846, -0.1877556806843498, -0.18667456473765223, -0.1855733270438779, -0.18445226634915898, -0.18331167377707103, -0.18215183297704418, -0.18097302026624104, -0.1797755047652521, -0.17855954852793157, -0.17732540666568333, -0.17607332746648197, -0.17480355250889992, -0.17351631677139331, -0.17221184873708734, -0.17089037049428377, -0.16955209783290204, -0.1681972403370558, -0.16682600147394872, -0.16543857867926975, -0.16403516343925414, -0.16261594136956659, -0.16118109229115835, -0.1597307903032359, -0.1582652038534771, -0.15678449580561865, -0.15528882350453604, -0.15377833883892672, -0.15225318830170576, -0.15071351304821246, -0.1491594489523275, -0.14759112666058766, -0.14600867164438927, -0.14441220425035728, -0.14280183974896235, -0.14117768838145825, -0.1395398554052083, -0.13788844113747092, -0.13622354099770648, -0.1345452455484647, -0.13285364053491355, -0.13114880692305975, -0.1294308209367197, -0.1276997540932836, -0.1259556732383261, -0.12419864057910496, -0.1224287137169932, -0.12064594567888545, -0.11885038494761681, -0.1170420754914334, -0.11522105679254979, -0.11338736387482752, -0.11154102733060785, -0.10968207334672976, -0.10781052372976403, -0.10592639593049079, -0.10402970306764958, -0.10212045395098664, -0.10019865310362591, -0.09826430078378737, -0.09631739300587559, -0.0943579215609611, -0.09238587403667545, -0.09040123383654083, -0.08840398019875363, -0.08639408821443899, -0.08437152884539866, -0.08233626894136373, -0.08028827125677401, -0.07822749446709627, -0.07615389318469871, -0.07406741797429556, -0.07196801536797645, -0.06985562787983313, -0.06773019402019827, -0.0655916483095066, -0.06343992129179303, -0.061274939547837394, -0.059096625707968226, -0.05690489846453519, -0.05469967258406216, -0.05248085891908919, -0.05024836441971434, -0.04800209214484382, -0.04574194127315998, -0.04346780711381527, -0.041179581116860695, -0.03887715088341661, -0.0365604001755944, -0.0342292089261751, -0.03188345324805307, -0.0295230054434523, -0.027147734012919186, -0.024757503664102922, -0.022352175320326042, -0.019931606128950768, -0.017495649469550664, -0.015044154961890389, -0.012576968473718534, -0.010093932128381571, -0.007594884312261131, -0.005079659682041561, -0.0025480891718105917, 5.828670879282071e-17]
x_u = [0.0, 0.005025124814209513, 0.010050250180982769, 0.015075375654738609, 0.02010050118968331, 0.025125626767135766, 0.030150752377032235, 0.035175878013099925, 0.04020100367105304, 0.04522612934777122, 0.05025125504087388, 0.05527638074847854, 0.060301506469053766, 0.06532663220132474, 0.07035175794420996, 0.07537688369677725, 0.08040200945821217, 0.08542713522779502, 0.09045226100488332, 0.09547738678889854, 0.1005025125630178, 0.10552763819323503, 0.11055276382351996, 0.11557788945386752, 0.12060301508427308, 0.1256281407147323, 0.1306532663452411, 0.13567839197579565, 0.14070351760639235, 0.14572864323702783, 0.15075376886769892, 0.15577889449840246, 0.1608040201291356, 0.16582914575989557, 0.17085427139067977, 0.17587939702148564, 0.18090452265231075, 0.18592964828315278, 0.19095477391400953, 0.19597989954487885, 0.2010050251757587, 0.20603015080664702, 0.211055276437542, 0.2160804020684417, 0.22110552769934444, 0.2261306533302484, 0.23115577896115197, 0.23618090459205351, 0.24120603022295145, 0.24623115585384434, 0.25125628148473056, 0.2562814071156089, 0.26130653274647786, 0.266331658377336, 0.2713567840081822, 0.27638190963901516, 0.2814070352698335, 0.28643216090063617, 0.29145728653142194, 0.2964824121621898, 0.3015075377929385, 0.3065326634236669, 0.3115577890543742, 0.3165829146850592, 0.32160804031572104, 0.32663316594635866, 0.3316582915769711, 0.33668341720755746, 0.34170854283811686, 0.34673366846864845, 0.3517587940991514, 0.3567839197296248, 0.3618090453600679, 0.3668341709904798, 0.3718592966208599, 0.37688442225120744, 0.3819095478815214, 0.38693467351180144, 0.39195979914204665, 0.3969849247722563, 0.4020100504024299, 0.40703517603256656, 0.41206030166266583, 0.417085427292727, 0.4221105529227494, 0.4271356785527326, 0.43216080418267583, 0.43718592981257864, 0.44221105544244044, 0.4472361810722606, 0.4522613067020387, 0.457286432331774, 0.4623115579614662, 0.46733668359111474, 0.472361809220719, 0.47738693485027867, 0.48241206047979307, 0.4874371861092619, 0.4924623117386846, 0.49748743736806067, 0.5025125629973897, 0.5075376886266714, 0.512562814255905, 0.5175879398850903, 0.5226130655142269, 0.5276381911433142, 0.5326633167723521, 0.5376884424013398, 0.5427135680302773, 0.5477386936591638, 0.5527638192879991, 0.5577889449167828, 0.5628140705455146, 0.567839196174194, 0.5728643218028207, 0.5778894474313941, 0.5829145730599141, 0.5879396986883803, 0.5929648243167922, 0.5979899499451495, 0.6030150755734518, 0.6080402012016988, 0.61306532682989, 0.6180904524580253, 0.6231155780861041, 0.6281407037141261, 0.6331658293420909, 0.6381909549699982, 0.6432160805978477, 0.648241206225639, 0.6532663318533717, 0.6582914574810452, 0.6633165831086596, 0.6683417087362142, 0.6733668343637088, 0.6783919599911429, 0.6834170856185161, 0.6884422112458282, 0.6934673368730787, 0.6984924625002673, 0.7035175881273935, 0.7085427137544569, 0.7135678393814572, 0.718592965008394, 0.7236180906352669, 0.7286432162620754, 0.733668341888819, 0.7386934675154977, 0.7437185931421106, 0.7487437187686575, 0.753768844395138, 0.7587939700215517, 0.7638190956478977, 0.7688442212741762, 0.7738693469003863, 0.7788944725265279, 0.7839195981526, 0.7889447237786025, 0.7939698494045349, 0.7989949750303966, 0.8040201006561871, 0.809045226281906, 0.8140703519075525, 0.8190954775331264, 0.824120603158627, 0.8291457287840538, 0.8341708544094062, 0.8391959800346834, 0.8442211056598854, 0.8492462312850112, 0.8542713569100603, 0.859296482535032, 0.8643216081599256, 0.8693467337847409, 0.8743718594094769, 0.879396985034133, 0.8844221106587087, 0.8894472362832029, 0.8944723619076155, 0.8994974875319454, 0.9045226131561919, 0.9095477387803544, 0.9145728644044321, 0.9195979900284244, 0.9246231156523304, 0.9296482412761492, 0.9346733668998802, 0.9396984925235224, 0.9447236181470753, 0.9497487437705378, 0.9547738693939092, 0.9597989950171885, 0.9648241206403747, 0.9698492462634672, 0.9748743718864651, 0.9798994975093672, 0.9849246231321728, 0.9899497487548807, 0.9949748743774901, 1.0]
y_u = [0.0, 0.042849816744864204, 0.059772187097823434, 0.07239852588790564, 0.08278396925098104, 0.0917248269259553, 0.09962970745323467, 0.10674151816577901, 0.1132186753064264, 0.11917134405501374, 0.12467984848587771, 0.1298049279246325, 0.13459386181058317, 0.13908433158391023, 0.14330696464140477, 0.14728707163782284, 0.15104586933039413, 0.15460136374989086, 0.15796900235864722, 0.16116216501929473, 0.1641925399479099, 0.1670704159658067, 0.16980491275030765, 0.17240416444740794, 0.1748754676990183, 0.17722540216396457, 0.1794599295344229, 0.18158447555948484, 0.18360399850981035, 0.18552304672615125, 0.18734580730651643, 0.1890761475447159, 0.190717650397211, 0.19227364499757316, 0.1937472330384029, 0.1951413116848304, 0.19645859356115453, 0.19770162425499443, 0.1988727977057274, 0.19997436978161653, 0.2010084702995862, 0.20197711370056656, 0.20288220855975622, 0.20372556608354458, 0.20450890772201824, 0.20523387200702686, 0.2059020207099804, 0.2065148444003057, 0.2070737674743554, 0.2075801527151541, 0.2080353054353933, 0.2084404772493069, 0.20879686951326606, 0.20910563646997757, 0.2093678881269069, 0.20958469289588114, 0.20975708001765, 0.20988604179243847, 0.2099725356351337, 0.21001748597166928, 0.21002178599134957, 0.20998629926827078, 0.20991186126359324, 0.20979928071919715, 0.2096493409521653, 0.20946280105858814, 0.20924039703433225, 0.20898284281966972, 0.20869083127399482, 0.20836503508626525, 0.20800610762627064, 0.20761468374136485, 0.20719138050287067, 0.20673679790598934, 0.20625151952670726, 0.2057361131388835, 0.20519113129443223, 0.20461711186925954, 0.2040145785773946, 0.20338404145555095, 0.2027259973201702, 0.2020409301988335, 0.20132931173777863, 0.2005916015871165, 0.19982824776522576, 0.1990396870036797, 0.1982263450739664, 0.19738863709715904, 0.19652696783761434, 0.19564173198169332, 0.19473331440242772, 0.19380209041098775, 0.19284842599574895, 0.19187267804969593, 0.1908751945868504, 0.1898563149483658, 0.18881636999888457, 0.18775568231371384, 0.18667456635733945, 0.1855733286537637, 0.1844522679491186, 0.18331167536697973, 0.1821518345567773, 0.1809730218356739, 0.17977550632425995, 0.17855955007638977, 0.17732540820346718, 0.17607332899346673, 0.17480355402496092, 0.17351631827640582, 0.17221185023092667, 0.1708903719768252, 0.16955209930402088, 0.16819724179662737, 0.1668260029218483, 0.16543858011537266, 0.16403516486343564, 0.162615942781702, 0.161181093691123, 0.15973079169090504, 0.15826520522872606, 0.1567844971683227, 0.15528882485457052, 0.15377834017616693, 0.15225318962602696, 0.15071351435949, 0.14915945025043661, 0.1475911279454037, 0.14600867291578754, 0.14441220550821304, 0.14280184099315094, 0.14117768961185492, 0.13953985662168839, 0.13788844233990968, 0.13622354218597924, 0.13454524672244678, 0.13285364169448022, 0.13114880806808632, 0.1294308220670815, 0.1276997552088559, 0.12595567433898416, 0.12419864166472414, 0.12242871478744878, 0.12064594673405271, 0.11885038598737106, 0.11704207651564998, 0.11522105780110395, 0.11338736486759456, 0.11154102830746308, 0.10968207430754849, 0.10781052467442155, 0.10592639685886242, 0.10402970397961059, 0.10212045484641234, 0.10019865398239161, 0.09826430164576835, 0.09631739385094716, 0.09435792238899854, 0.09238587484755409, 0.09040123463013597, 0.08840398097494055, 0.08639408897309299, 0.08437152958639503, 0.0823362696645778, 0.08028827196208105, 0.07822749515437159, 0.07615389385381761, 0.07406741862513333, 0.07196801600040842, 0.06985562849373458, 0.06773019461544448, 0.0655916488859729, 0.06343992184935472, 0.06127494008636975, 0.05909662622734656, 0.05690489896463479, 0.054699673064758335, 0.05248085938025724, 0.05024836486122957, 0.04800209256658152, 0.04574194167499545, 0.04346780749562381, 0.04117958147851761, 0.038877151224797186, 0.03656040049657395, 0.034229209226628914, 0.03188345352785646, 0.02952300570248055, 0.027147734251047606, 0.024757503881206806, 0.02235217551628069, 0.019931606303631482, 0.01749564962283274, 0.015044155093649128, 0.012576968583829232, 0.010093932216719533, 0.007594884378701652, 0.005079659726459943, 0.002548089194082133, -5.828670879282071e-17]
x_l = Scale_factor*np.array(x_l)
y_l = Scale_factor*np.array(y_l)
x_u = Scale_factor*np.array(x_u)
y_u = Scale_factor*np.array(y_u)
thickness = max(y_u)*2
points_l = []
points_u = []
for i in range(0,len(x_l)):
point_l = (x_l[i],y_l[i],0)
point_u = (x_u[i],y_u[i],0)
points_l.append(point_l)
points_u.append(point_u)
points_l.append(points_l[0])
points_u.append(points_u[0])
Polygon_u = Part.makePolygon(points_u)
Polygon_l = Part.makePolygon(points_l)
## Translate polygon
dX = 4 #mm spacing between the Airfoils in horizontal direction
dY = 8 #mm spacing between the Airfoils in vertical direction
chord = Scale_factor
P_L = (chord + dX)/2
P_T = dY + thickness
Polygon_l.translate((P_L,P_T,0))
Part.show(Polygon_u)
Part.show(Polygon_l)
## Deciding the number of airfoils and the length of the fluid domain
X_L = 40 ## mm inlet, empty
X_T = 60 ##mm outlet, empty
nr_airfoils = 10 ## The number of air foils in the first row
depth_airfoils = nr_airfoils * 2 * P_L - dX ## The length from the first point of the first airfoil to the last point of the last airfoil
total_depth = X_L + depth_airfoils + X_T ## Total domain length for CFD
fluid_domain = Part.makeBox(total_depth,P_T,1)
fluid_domain.translate((-X_L,0,0))
Part.show(fluid_domain)
print(thickness)