-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from upb-lea/component_study
Component study
- Loading branch information
Showing
20 changed files
with
1,581 additions
and
1,005 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import numpy as np | ||
from matplotlib import pyplot as plt | ||
import femmt as fmt | ||
|
||
|
||
phi = np.linspace(0, 2*np.pi, 100) | ||
t = | ||
i1 = 8*np.sin(phi) + 1*np.sin(2*phi+5) | ||
i2 = 8*np.cos(phi) - 2*np.cos(2*phi+4) | ||
print(np.mean(np.mean(i1))) | ||
print(np.mean(np.mean(i2))) | ||
|
||
i1 = i1 - np.mean(i1) | ||
i2 = i2 - np.mean(i2) | ||
|
||
res1 = fmt.fft(i1, mode='time') | ||
print(res1) | ||
fmt.fft(i2) | ||
def wizard_n_ffts(): | ||
# TODO: function that takes n ffts with a certain energy limit and createst the missing harmonic results! | ||
pass | ||
|
||
|
||
plt.plot(phi, i1) | ||
plt.plot(phi, i2) | ||
plt.show() | ||
|
||
print(np.mean(np.mean(i1))) | ||
print(np.mean(np.mean(i2))) | ||
|
||
i1.tofile('i1.csv', sep = ',') | ||
i2.tofile('i2.csv', sep = ',') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-0.949335031916507,-0.3983194573493502,0.16538055185747305,0.7387912352691968,1.3187333888511328,1.9018491696578745,2.4846320710296417,3.063459682839627,3.6346288049412045,4.194392442133938,4.738998176351141,5.264727386903681,5.767934772905653,6.245087623738862,6.69280428373131,7.107891266140167,7.48737848891478,7.8285521303079575,8.128984635810863,8.386561448590614,8.599504082975631,8.766389213821682,8.886163512965933,8.95815402652137,8.982073952496762,8.95802374611445,8.886487549172317,8.76832500877197,8.604758618628294,8.39735678191876,8.148012857191853,7.858920507251242,7.532545724251562,7.171595951649542,6.778986764412629,6.3578066023640165,5.9112800772234015,5.44273039139555,4.955541415605424,4.453119972953641,3.9388588688829484,3.4161011900536535,2.8881063705076264,2.3580184911690423,1.8288372392220216,1.3033919078700458,0.7843187651741715,0.27404206393084357,-0.22524109619037955,-0.7115719067885304,-1.1832369074367637,-1.6387709459034816,-2.0769560933538487,-2.4968166312821003,-2.897610289932671,-3.2788159776839456,-3.6401182963348533,-3.9813891875621676,-4.302667100201941,-4.60413410574419,-4.8860914199178405,-5.148933811002249,-5.393123390178039,-5.6191632856001155,-5.827571699851881,-6.018856840069519,-6.193493191493142,-6.351899578823383,-6.494419425981597,-6.621303584252703,-6.732696052006789,-6.828622857023403,-6.908984315743387,-6.973550823482678,-7.021962266754964,-7.053731084401669,-7.0682489392802905,-7.064796897885807,-7.042558952535804,-7.000638660673136,-6.938078619422258,-6.853882441709894,-6.747038853886355,-6.616547494631299,-6.461445961667487,-6.28083762699687,-6.073919723453635,-5.840011195649117,-5.578579807042095,-5.289268001946622,-4.971917036694698,-4.6265889176726125,-4.253585715188232,-3.853465860614235,-3.4270570793861483,-2.9754656635008296,-2.5000818433518393,-2.002581079159464,-1.484921155942146,-0.9493350319165091 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9.214214369309952,8.995979441037885,8.727813771430574,8.413450112432951,8.05697907440538,7.6627872029302235,7.23549183043121,6.779873728991512,6.300808620037098,5.8031986089590335,5.291904608106693,4.771680789991246,4.247112074366025,3.722555598733361,3.2020870526589236,2.6894526731871475,2.1880276030020895,1.7007812063237864,1.2302498216046074,0.7785173067743225,0.3472036040755737,-0.06253858048248209,-0.45001902120934756,-0.8149973107161275,-1.1576625912382066,-1.4786061026191437,-1.7787870869540046,-2.0594926974825496,-2.3222926560964123,-2.5689894882211703,-2.801565234496546,-3.022125594470934,-3.2328424975558274,-3.435896120112647,-3.633417374395622,-3.8274318850476967,-4.019806442113127,-4.212198876531939,-4.406012245522152,-4.602354142092172,-4.802001856350256,-5.005374017700564,-5.212509238039459,-5.423052158464272,-5.636247177691479,-5.850940011373665,-6.065587099902027,-6.278272750223873,-6.486733766840402,-6.688391200600709,-6.880388723233901,-7.059637022728758,-7.222863511520458,-7.366666547660974,-7.487573290236521,-7.582100245546645,-7.646815511042416,-7.6784016905575605,-7.673718437519351,-7.629863582891036,-7.544231821597641,-7.41456996487126,-7.239027815801644,-7.016203790612254,-6.745184487772272,-6.425577499740943,-6.057536866449119,-5.641780683894078,-5.179600503634692,-4.672862287571641,-4.123998815125254,-3.5359935746598867,-2.912356305590856,-2.2570904898930766,-1.574653219588347,-0.8699079881713894,-0.14807106689423724,0.5853477704484125,1.3246093197558277,2.06381288391685,2.796967080313131,3.5180624764014414,4.221144980346805,4.900388899658296,5.55016858387233,6.165127587494323,6.740244326333586,7.270893253467188,7.752900649504176,8.18259420450673,8.556845664543951,8.873105922886674,9.129432052593222,9.324505901828374,9.457644003715856,9.528798686771,9.538550407856983,9.48809146499139,9.379201380044952,9.214214369309952 |
85 changes: 85 additions & 0 deletions
85
femmt/examples/component_study/transformer_component_study.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import femmt as fmt | ||
import os | ||
import numpy as np | ||
|
||
def transformer_component_study(onelab_folder: str = None, show_visual_outputs: bool = True, is_test: bool = False): | ||
switching_frequency = 180000 | ||
|
||
# max efficient | ||
i_primary = np.genfromtxt("i1.csv", delimiter=",", dtype=float) | ||
i_secondary = np.genfromtxt("i2.csv", delimiter=",", dtype=float) | ||
|
||
length_i_primary = len(i_primary) | ||
time = np.linspace(0, 1 / switching_frequency, length_i_primary) | ||
|
||
i_1 = [time, i_primary] | ||
i_2 = [time, i_secondary] | ||
|
||
example_results_folder = os.path.join(os.path.dirname(__file__), "results") | ||
if not os.path.exists(example_results_folder): | ||
os.mkdir(example_results_folder) | ||
|
||
|
||
|
||
# Example for a transformer_component_study. | ||
working_directory = os.path.join(example_results_folder, "transformer_component_study") | ||
if not os.path.exists(working_directory): | ||
os.mkdir(working_directory) | ||
|
||
# 1. chose simulation type | ||
geo = fmt.MagneticComponent(component_type=fmt.ComponentType.Transformer, working_directory=working_directory, | ||
silent=True, is_gui=is_test) | ||
|
||
# This line is for automated pytest running on github only. Please ignore this line! | ||
if onelab_folder is not None: geo.file_data.onelab_folder_path = onelab_folder | ||
|
||
# 2. set core parameters | ||
core_dimensions = fmt.dtos.SingleCoreDimensions(core_inner_diameter=0.015, window_w=0.012, window_h=0.0295) | ||
core = fmt.Core(core_dimensions=core_dimensions, mu_r_abs=3100, phi_mu_deg=12, sigma=1.2, | ||
permeability_datasource=fmt.MaterialDataSource.Custom, | ||
permittivity_datasource=fmt.MaterialDataSource.Custom) | ||
geo.set_core(core) | ||
|
||
# 3. set air gap parameters | ||
air_gaps = fmt.AirGaps(fmt.AirGapMethod.Percent, core) | ||
air_gaps.add_air_gap(fmt.AirGapLegPosition.CenterLeg, 0.0005, 50) | ||
geo.set_air_gaps(air_gaps) | ||
|
||
# 4. set insulation | ||
insulation = fmt.Insulation() | ||
insulation.add_core_insulations(0.001, 0.001, 0.002, 0.001) | ||
insulation.add_winding_insulations([[0.0002, 0.001], | ||
[0.001, 0.0002]]) | ||
geo.set_insulation(insulation) | ||
|
||
# 5. create winding window and virtual winding windows (vww) | ||
winding_window = fmt.WindingWindow(core, insulation) | ||
bot, top = winding_window.split_window(fmt.WindingWindowSplit.HorizontalSplit, split_distance=0.001) | ||
|
||
# 6. create conductors and set parameters | ||
winding1 = fmt.Conductor(0, fmt.Conductivity.Copper) | ||
winding1.set_solid_round_conductor(0.0011, fmt.ConductorArrangement.Square) | ||
|
||
# winding1 = fmt.Conductor(0, fmt.Conductivity.Copper) | ||
# winding1.set_litz_round_conductor(0.0011, 50, 0.00011, None, fmt.ConductorArrangement.Square) | ||
|
||
# winding2 = fmt.Conductor(1, fmt.Conductivity.Copper) | ||
# winding2.set_solid_round_conductor(0.0011, fmt.ConductorArrangement.Square) | ||
|
||
winding2 = fmt.Conductor(1, fmt.Conductivity.Copper) | ||
winding2.set_solid_round_conductor(0.0011, fmt.ConductorArrangement.Square) | ||
winding2.parallel = False | ||
# winding2.set_litz_round_conductor(0.0011, 50, 0.00011, None, fmt.ConductorArrangement.Square) | ||
|
||
# 7. add conductor to vww and add winding window to MagneticComponent | ||
bot.set_winding(winding2, 10, None) | ||
top.set_winding(winding1, 10, None) | ||
geo.set_winding_windows([winding_window]) | ||
|
||
# 8. start simulation with given frequency, currents and phases | ||
geo.create_model(freq=switching_frequency, pre_visualize_geometry=show_visual_outputs) | ||
geo.component_study(time_current_vectors=[i_1, i_2]) | ||
|
||
|
||
if __name__ == "__main__": | ||
transformer_component_study(show_visual_outputs=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.