Skip to content

Commit

Permalink
Merge pull request #44 from upb-lea/modular_core
Browse files Browse the repository at this point in the history
Modular core
  • Loading branch information
gituser789 authored Aug 25, 2023
2 parents 9de5d1d + 02f4b4f commit 1de2efb
Show file tree
Hide file tree
Showing 37 changed files with 2,170 additions and 1,158 deletions.
443 changes: 202 additions & 241 deletions femmt/component.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion femmt/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ def draw_conductors(self, draw_top_down=True):
0,
self.mesh_data.c_conductor[num]])
i += 1
x += winding.conductor_radius * 2 + self.insulation.cond_cond[num][num] # one step from left to right
x += winding.conductor_radius * 2 + self.insulation.cond_cond[num][num] # TODO: anisotrop insulation # one step from left to right
y += winding.conductor_radius * 2 + self.insulation.cond_cond[num][num] # bot to top
x = left_bound + winding.conductor_radius # always the same

Expand Down
1 change: 1 addition & 0 deletions femmt/dtos.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class SingleCoreDimensions:
core_inner_diameter: float
window_w: float
window_h: float
core_h: float


@dataclass
Expand Down
143 changes: 79 additions & 64 deletions femmt/electro_magnetic/ind_axi_python_controlled.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ Flag_Circuit = Flag_ImposedVoltage;
// 1 means full cylinder
SymFactor = 1. ;
CoefGeo = 2*Pi*SymFactor ; // axisymmetry +/* symmetry factor */
n_windings = Number_of_Windings; //added by Othman
n_windings = Number_of_Windings;

// ----------------------
// Physical numbers
// ----------------------
OUTBND = 111111;
AIR = 110000;
AIR_EXT = 110001;
IRON = 120000;
AIR_COND = 1000000;
CORE_PN = 120000;


//physical numbers of conductors in n transformer
For n In {1:n_windings}
Expand All @@ -47,49 +49,63 @@ Group{
// Physical Domains
// ----------------------
Air = Region[{AIR, AIR_EXT}];
Iron = Region[{IRON}];

// Non Conducting Domain:
// Initialize the core-shell domain region to air
DomainCC = Region[{Air}];
Core = Region[{}];
// Core Domain
For n In {1:nCoreParts}
CorePart~{n} = Region[{(CORE_PN+n-1)}];
Core += Region[{(CORE_PN+n-1)}];
EndFor

// Add the iron region to the core-shell domain region
If(!Flag_Conducting_Core)
DomainCC += Region[{Iron}];
EndIf

// Boundary Conditions
// including symmetry
OuterBoundary = Region[{OUTBND}];

// Current Conducting Domains
// Create a region for the winding
For n In {1:n_windings} // loop over each winding //added by Othman
For n In {1:n_windings} // loop over each winding
Winding~{n} = Region[{}]; // create a region for the winding
StrandedWinding~{n} = Region[{}]; // create a region for the stranded winding
EndFor


// Loop over each winding
For n In {1:n_windings}
nbturns~{n} = NbrCond~{n} / SymFactor;
For winding_number In {1:n_windings}
nbturns~{winding_number} = NbrCond~{winding_number} / SymFactor;
// Loop over each turn in this winding to create a region for turns and then adding it to the winding
For winding_number In {1:nbturns~{n}}
Turn~{n}~{winding_number} = Region[{(iCOND~{n}+winding_number-1)}];
Winding~{n} += Region[{(iCOND~{n}+winding_number-1)}];
TurnStrand~{n}~{winding_number} = Region[{(istrandedCOND~{n}+winding_number-1)}];
StrandedWinding~{n} += Region[{(istrandedCOND~{n}+winding_number-1)}];
For turn_number In {1:nbturns~{winding_number}}
// Solid
Turn~{winding_number}~{turn_number} = Region[{(iCOND~{winding_number}+turn_number-1)}];
Winding~{winding_number} += Region[{(iCOND~{winding_number}+turn_number-1)}];
Air += Region[{(AIR_COND+iCOND~{winding_number}+turn_number-1)}];
// Stranded
TurnStrand~{winding_number}~{turn_number} = Region[{(istrandedCOND~{winding_number}+turn_number-1)}];
StrandedWinding~{winding_number} += Region[{(istrandedCOND~{winding_number}+turn_number-1)}];
Air += Region[{(AIR_COND+istrandedCOND~{winding_number}+turn_number-1)}];
EndFor
EndFor
// Add this winding to the core domain region


// Non Conducting Domain:
// Initialize the core-shell domain region to air
DomainCC = Region[{Air}];

// Add the Core region to the core-shell domain region
If(!Flag_Conducting_Core)
DomainCC += Region[{Core}];
EndIf

// Boundary Conditions
// including symmetry
OuterBoundary = Region[{OUTBND}];

// Add the winding to the core domain region
For n In {1:n_windings}
DomainC += Region[{Winding~{n}}] ;
EndFor
// Add the iron region to the core domain region
// Add the Core region to the core domain region
If(Flag_Conducting_Core)
DomainC += Region[{Iron}] ;
DomainC += Region[{Core}];
EndIf
// Add this stranded winding to the shell domain region
For n In {1:n_windings} //added by Othman
For n In {1:n_windings}
DomainS += Region[{StrandedWinding~{n}}] ;
EndFor
// Add the shell domain to the core-shell domain region
Expand All @@ -102,20 +118,20 @@ Group{
Domain_Lin += Region[{Winding~{n}, StrandedWinding~{n}}];
EndFor
Domain_Lin_NoJs = Region[{Air}];
Domain_NonLin = Region[{Iron}];
Domain_NonLin = Region[{Core}];
Else
Domain_Lin = Region[{Air, Iron}];
Domain_Lin = Region[{Air, Core}];
For n In {1:n_windings}
Domain_Lin += Region[{Winding~{n}, StrandedWinding~{n}}];
EndFor
Domain_Lin_NoJs = Region[{Air, Iron}];
Domain_Lin_NoJs = Region[{Air, Core}];
Domain_NonLin = Region[{}];
EndIf
// Initialize the main domain to the core and core-shell domains
Domain = Region[{DomainC, DomainCC}] ;

// Loop over each winding and add its regions to the corresponding conductor domain
For n In {1:n_windings} // added by Othman
For n In {1:n_windings}
DomainCond~{n} += Region[{Winding~{n}, StrandedWinding~{n}}] ;
EndFor

Expand Down Expand Up @@ -145,7 +161,7 @@ Group{

Inductance_Cir = Region[ {} ];

For n In {1:n_windings} //added by Othman
For n In {1:n_windings}
Capacitance_Cir~{n} = Region[{}] ;
EndFor
Capacitance_Cir = {};
Expand Down Expand Up @@ -176,7 +192,7 @@ Function {

// in non-stranded domains, def. AreaCell to 1 (neutral element of mutiplication)

AreaCell[#{Air, Iron}] = 1.;
AreaCell[#{Air, Core}] = 1.;
For n In {1:n_windings}
AreaCell[#{Winding~{n}}] = 1.;
EndFor
Expand All @@ -192,11 +208,11 @@ Function {
EndFor

If(Flag_Conducting_Core)
sigma[#{Iron}] = sigma_core;
sigma[#{Core}] = Complex[sigma_core, sigma_core_imag];
sigma[#{Air}] = 0.;
EndIf
If(!Flag_Conducting_Core)
sigma[#{Air, Iron}] = 0.;
sigma[#{Air, Core}] = 0.;
EndIf

// nu: reluctivity
Expand All @@ -211,33 +227,32 @@ Function {
// Hysteresis Loss
// Imaginary Part Of Permeability
// Liste von Lukas hinterlegen
//mu_imag[ #{Iron} ] = mu0 * f_mu_imag[$1, $2];
//mu_imag[ #{Core} ] = mu0 * f_mu_imag[$1, $2];

If(!Flag_NL)
If(Flag_Fixed_Loss_Angle)
mu[#{Iron}] = Complex[mu0*mur_real, -mu0*mur_imag] ;
nu[#{Iron}] = 1/mu[$1, $2] ;
mu[#{Core}] = Complex[mu0*mur_real, -mu0*mur_imag] ;
nu[#{Core}] = 1/mu[$1, $2] ;
ElseIf(Flag_Permeability_From_Data)
//mu[#{Iron}] = Complex[mu0*(mur^2-f_mu_imag[$1, $2]^2)^(0.5), mu0*f_mu_imag[$1, $2]] ; // TODO
mu[#{Iron}] = Complex[mu0*f_mu_real[$1], -mu0*f_mu_imag[$1]] ;
nu[#{Iron}] = 1/mu[$1, $2] ;
mu[#{Core}] = Complex[mu0*f_mu_real[$1], -mu0*f_mu_imag[$1]] ;
nu[#{Core}] = 1/mu[$1, $2] ;
Else
mu[#{Iron}] = mu0*mur ;
nu[#{Iron}] = 1/mu[$1, $2] ;
mu[#{Core}] = mu0*mur ;
nu[#{Core}] = 1/mu[$1, $2] ;
EndIf

Else
//nu[ #{Iron} ] = nu_3kW[$1] ;
//h[ #{Iron} ] = h_3kW[$1];
//dhdb_NL[ #{Iron} ]= dhdb_3kW_NL[$1] ;
//dhdb[ #{Iron} ] = dhdb_3kW[$1] ;

//nu[ #{Iron} ] = nu_N95[$1] ;
nu[ #{Iron} ] = nu~{Core_Material}[$1] ;
h[ #{Iron} ] = h~{Core_Material}[$1];
//dhdb_NL[ #{Iron} ]= dhdb_95_NL[$1] ;
dhdb_NL[ #{Iron} ]= dhdb_95100_NL[$1] ;
dhdb[ #{Iron} ] = dhdb~{Core_Material}[$1] ;
//nu[ #{Core} ] = nu_3kW[$1] ;
//h[ #{Core} ] = h_3kW[$1];
//dhdb_NL[ #{Core} ]= dhdb_3kW_NL[$1] ;
//dhdb[ #{Core} ] = dhdb_3kW[$1] ;

//nu[ #{Core} ] = nu_N95[$1] ;
nu[ #{Core} ] = nu~{Core_Material}[$1] ;
h[ #{Core} ] = h~{Core_Material}[$1];
//dhdb_NL[ #{Core} ]= dhdb_95_NL[$1] ;
dhdb_NL[ #{Core} ]= dhdb_95100_NL[$1] ;
dhdb[ #{Core} ] = dhdb~{Core_Material}[$1] ;
EndIf

// Excitation Current
Expand All @@ -251,7 +266,7 @@ Function {

// Auxiliary functions for post-processing
nuOm[#{Air}] = nu[]*Complex[0.,1.];
nuOm[#{Iron}] = -nu[$1]*Complex[0.,1.];
nuOm[#{Core}] = -nu[$1]*Complex[0.,1.];
//nuOm[#{Winding1, Winding2, Winding3}] = Complex[ 2 * Pi * Freq * Im[nu[]], -Re[nu[]] ];


Expand Down Expand Up @@ -327,7 +342,7 @@ Constraint {
{ Name Voltage_2D ;
Case{
If(Flag_Conducting_Core)
{ Region Iron ; Value 0; }
{ Region Core ; Value 0; }
EndIf
}
}
Expand Down Expand Up @@ -389,7 +404,7 @@ Resolution {

Operation {


CreateDir[DirResValsCore];
For n In {1:n_windings}
CreateDir[DirResValsWinding~{n}];
EndFor
Expand Down Expand Up @@ -437,7 +452,7 @@ PostProcessing {
// Electrical Field

{ Name e ; Value { Term { [ -1*(Dt[{a}]+{ur}/CoefGeo) ] ; In Domain ; Jacobian Vol ; } } }
{ Name MagEz ; Value { Term { [ -1*(Dt[{a}]+{ur}/CoefGeo) ] ; In Domain ; Jacobian Vol ; } } }
{ Name MagEz ; Value { Term { [ Norm[ -1*(Dt[{a}]+{ur}/CoefGeo) ] ] ; In Domain ; Jacobian Vol ; } } }



Expand Down Expand Up @@ -468,8 +483,8 @@ PostProcessing {

{ Name nur ; Value { Term { [ Norm[ nu[{d a}, Freq] / mu0 ] ] ; In Domain ; Jacobian Vol ; } } }
//{ Name mur ; Value { Term { [ 1 / Norm[ nu[{d a}, Freq] / mu0 ] ] ; In Domain ; Jacobian Vol ; } } }
{ Name mur ; Value { Term { [ 1 / Norm [Im[ nu[{d a}, Freq]] * mu0 ] ] ; In Iron ; Jacobian Vol ; } } }
{ Name mur_norm ; Value { Term { [ Norm [Im[ mu[{d a}, Freq]] / mu0 ] ] ; In Iron ; Jacobian Vol ; } } }
{ Name mur ; Value { Term { [ 1 / Norm [Im[ nu[{d a}, Freq]] * mu0 ] ] ; In Core ; Jacobian Vol ; } } }
{ Name mur_norm ; Value { Term { [ Norm [Im[ mu[{d a}, Freq]] / mu0 ] ] ; In Core ; Jacobian Vol ; } } }
{ Name mur_re ; Value { Term { [ Re[ 1/nu[{d a}, Freq] / mu0 ] ] ; In Domain ; Jacobian Vol ; } } }
{ Name mur_im ; Value { Term { [ Norm [ Im[ 1/nu[{d a}, Freq] / mu0 ] ] ] ; In Domain ; Jacobian Vol ; } } }
{ Name nur_re ; Value { Term { [ Re[ nu[{d a}, Freq] * mu0 ] ] ; In Domain ; Jacobian Vol ; } } } // := mur_re / (mur_re^2 + mur_im^2)
Expand Down Expand Up @@ -570,15 +585,15 @@ PostProcessing {
((Norm[{d a}]*2 / t_fall )^alpha) * t_fall
// 10 abschnitte reinbauen
// python überprüfung + vorfaktoren zu NULL
) ] ; In Iron ; Jacobian Vol ; Integration II ;} } }
) ] ; In Core ; Jacobian Vol ; Integration II ;} } }
EndIf

If(Flag_Steinmetz_loss)
{ Name pSE ; Value { Integral { [ CoefGeo * ki * Freq^alpha * (Norm[{d a}])^beta
] ; In Iron ; Jacobian Vol ; Integration II ;} } }
] ; In Core ; Jacobian Vol ; Integration II ;} } }

{ Name pSE_density ; Value { Integral { [ CoefGeo* ki * Freq^alpha * (Norm[{d a}])^beta
] ; In Iron ; Jacobian Vol ; Integration II ;} } }
] ; In Core ; Jacobian Vol ; Integration II ;} } }
EndIf


Expand All @@ -589,11 +604,11 @@ PostProcessing {
{ Name p_hyst ; Value { Integral {
// [ 0.5 * CoefGeo * 2*Pi*Freq * Im[mu[Norm[{d a}], Freq]] * SquNorm[nu[Norm[{d a}], Freq] * Norm[{d a}]] ] ;
[ - 0.5 * CoefGeo * 2*Pi*Freq * Im[mu[{d a}, Freq]] * SquNorm[nu[{d a}, Freq] * {d a}] ] ;
In Iron ; Jacobian Vol ; Integration II ;} } } // TODO: mur 2350 | general mur; multiplication at simulation begin with loss angle
In Core ; Jacobian Vol ; Integration II ;} } }

{ Name p_hyst_density ; Value { Integral {
[ - 0.5 * CoefGeo/ElementVol[] * 2*Pi*Freq * Im[mu[{d a}, Freq]] * SquNorm[nu[Norm[{d a}], Freq] * {d a}] ] ;
In Iron ; Jacobian Vol ; Integration II ;} } }
In Core ; Jacobian Vol ; Integration II ;} } }



Expand Down
24 changes: 14 additions & 10 deletions femmt/electro_magnetic/values.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PostOperation Get_global UsingPost MagDyn_a {

// Windings Total
// Solid
//Print[ SoF[ DomainC ], OnGlobal, Format TimeTable, File > Sprintf("results/SF_iron.dat")] ; // TODO: Complex power
//Print[ SoF[ DomainC ], OnGlobal, Format TimeTable, File > Sprintf("results/SF_Core.dat")] ; // TODO: Complex power
//Print[ j2F[ Winding~{1} ], OnGlobal, Format TimeTable, File > StrCat[DirResVals, "j2F_1.dat"]] ;

For n In {1:n_windings}
Expand Down Expand Up @@ -53,27 +53,31 @@ PostOperation Get_global UsingPost MagDyn_a {

// Core

// Eddy Current Losses according to sigma in core/iron
Print[ j2F[ Iron ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"CoreEddyCurrentLosses.dat"]] ;
// Eddy Current Losses according to sigma in Core
Print[ j2F[ Core ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"CoreEddyCurrentLosses.dat"]] ;

// Hysteresis Losses according to complex permeability in core/iron
Print[ p_hyst[ Iron ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"p_hyst.dat"]] ;// Core losses
// Hysteresis Losses according to complex permeability in Core
Print[ p_hyst[ Core ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"p_hyst.dat"]] ;// Core losses
For n In {1:nCoreParts}
Print[ p_hyst[ CorePart~{n} ], OnGlobal , Format TimeTable, File > Sprintf[StrCat[DirResValsCore, "p_hyst_%g.dat"], n]] ;
Print[ j2F[ CorePart~{n} ], OnGlobal , Format TimeTable, File > Sprintf[StrCat[DirResValsCore, "CoreEddyCurrentLosses_%g.dat"], n]] ;
EndFor

// Steinmetz Core Losses
If(Flag_Generalized_Steinmetz_loss)
Print[ piGSE[ Iron ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"piGSE.dat"]] ;// Core losses
Print[ piGSE[ Iron ], OnGlobal, Format Table];
Print[ piGSE[ Core ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"piGSE.dat"]] ;// Core losses
Print[ piGSE[ Core ], OnGlobal, Format Table];
EndIf

If(Flag_Steinmetz_loss)
Print[ pSE[ Iron ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"pSE.dat"]] ;// Core losses
Print[ pSE[ Iron ], OnGlobal, Format Table];
Print[ pSE[ Core ], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"pSE.dat"]] ;// Core losses
Print[ pSE[ Core ], OnGlobal, Format Table];
EndIf


// Stored Energy
Print[ MagEnergy[Domain], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"ME.dat"], LastTimeStepOnly, StoreInVariable $MagEnergy];
// Print[ MagEnergy[Iron], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"ME_iron.dat"], LastTimeStepOnly, StoreInVariable $MagEnergy];
// Print[ MagEnergy[Core], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"ME_Core.dat"], LastTimeStepOnly, StoreInVariable $MagEnergy];
// Print[ MagEnergy[Air], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"ME_air.dat"], LastTimeStepOnly, StoreInVariable $MagEnergy];
// Print[ MagEnergy[Winding1], OnGlobal, Format TimeTable, File > StrCat[DirResVals,"ME_winding1.dat"], LastTimeStepOnly, StoreInVariable $MagEnergy];

Expand Down
20 changes: 20 additions & 0 deletions femmt/enumerations.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@ class CenterTappedInterleavingType(IntEnum):
TypeC = 4


class InterleavingSchemesFoilLitz(str, Enum):
"""
----sec---
ooo-primary-ooo
ooo-primary-ooo
---ter---
---sec---
ooo-primary-ooo
ooo-primary-ooo
---ter---
"""
ter_3_4_ter_sec_4_3_sec = "ter_3_4_ter_sec_4_3_sec"
ter_4_3_ter_sec_3_4_sec = "ter_4_3_ter_sec_3_4_sec"
ter_3_4_sec_ter_4_3_sec = "ter_3_4_sec_ter_4_3_sec"
ter_4_3_sec_ter_3_4_sec = "ter_4_3_sec_ter_3_4_sec"
ter_sec_3_4_4_3_sec_ter = "ter_sec_3_4_4_3_ter_sec"
ter_sec_4_3_3_4_sec_ter = "ter_sec_4_3_3_4_ter_sec"
_4_3_ter_sec__sec_ter_3_4 = "4_3_ter_sec_sec_ter_3_4"


class ConductorType(IntEnum):
"""Sets the type of the conductor.
"""
Expand Down
Loading

0 comments on commit 1de2efb

Please sign in to comment.