Commit 3be33db6 authored by Pries, Jason's avatar Pries, Jason

Partial Commit on Synchronous Reluctance Rotor Template

parent 2704ddd8
......@@ -4,7 +4,7 @@ set(SOURCE_FILES
./include/ModelTemplates.hpp
./src/DistributedWindingStator.h ./src/DistributedWindingStator.cpp
)
src/SynchronousReluctanceRotor.cpp src/SynchronousReluctanceRotor.h src/ModelTemplate.h)
add_library(model_templates SHARED ${SOURCE_FILES})
......
......@@ -2,5 +2,6 @@
#define OERSTED_MODELTEMPLATES_H
#include "../src/DistributedWindingStator.h"
#include "../src/SynchronousReluctanceRotor.h"
#endif //OERSTED_MODELTEMPLATES_H
#include "DistributedWindingStator.h"
void DistributedWindingStator::add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin, size_t Nt) {
void DistributedWindingStator::add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin) {
// Dimensions are approximate, sketch.solve() + constraints will impose real values
double_t at = M_PI / Teeth;
double_t at = M_PI / TotalTeeth;
double_t ri = InnerRadius;
double_t rb = ri + ToothFaceThickness + SlotDepth;
double_t ro = rb + BackironThickness;
double_t rof = rb - SlotWidth / 2.0;
double_t rif = ri + SlotOpening + SlotWidth / 2.0;
double_t aso = at - at * SlotOpening * Teeth / (2.0 * M_PI * ri);
double_t aso = at - at * SlotOpening * TotalTeeth / (2.0 * M_PI * ri);
double_t rso = ri + ToothFaceThickness;
double_t rf = SlotWidth / 2.0;
double_t af = at - M_PI_2;
// Construct geometry
V.resize(12);
V[0] = s.new_element<Vertex>(ri,0.0);
V[1] = s.new_element<Vertex>(ro,0.0);
V[2] = s.new_element<Vertex>(ro * cos(at), ro * sin(at));
......@@ -28,6 +29,7 @@ void DistributedWindingStator::add_to_sketch(Sketch &s, std::shared_ptr<Vertex>
V[10] = s.new_element<Vertex>(V[5]->x() + rf * cos(af), V[5]->y() + rf * sin(af));
V[11] = s.new_element<Vertex>(V[4]->x() + rf * cos(af), V[4]->y() + rf * sin(af));
L.resize(7);
L[0] = s.new_element<LineSegment>(V[0],V[1]);
L[1] = s.new_element<LineSegment>(V[3],V[2],true); // for construction
L[2] = s.new_element<LineSegment>(V[6],V[3],true); // for construction
......@@ -36,6 +38,7 @@ void DistributedWindingStator::add_to_sketch(Sketch &s, std::shared_ptr<Vertex>
L[5] = s.new_element<LineSegment>(V[9],V[6]);
L[6] = s.new_element<LineSegment>(V[10],V[11]);
C.resize(5);
C[0] = s.new_element<CircularArc>(V[0],V[8],origin,ri);
C[1] = s.new_element<CircularArc>(V[1],V[2],origin,ro);
C[2] = s.new_element<CircularArc>(V[8],V[7],origin,ri);
......@@ -63,7 +66,7 @@ void DistributedWindingStator::add_to_sketch(Sketch &s, std::shared_ptr<Vertex>
s.new_element<Distance<LineSegment>>(L[3],L[4],SlotOpening / 2.0);
at = 180.0 / Teeth;
at = 180.0 / TotalTeeth;
s.new_element<Angle>(L[0],L[1],at);
double_t tol = s.solve();
......@@ -80,6 +83,12 @@ void DistributedWindingStator::add_to_sketch(Sketch &s, std::shared_ptr<Vertex>
// Rotational Copy
copy_curves.insert(copy_curves.end(),mc->curves().begin(),mc->curves().end());
at = 360.0 / Teeth;
std::shared_ptr<RotateCopy> rc = s.new_element<RotateCopy>(copy_curves,origin,at,Nt-1,true);
at = 360.0 / TotalTeeth;
std::shared_ptr<RotateCopy> rc = s.new_element<RotateCopy>(copy_curves,origin,at,ModeledTeeth-1,true);
if (Convexify) {
std::shared_ptr V0p = s.select_periodic_vertex(V[0],origin, (360.0 * ModeledTeeth) / TotalTeeth);
s.new_element<LineSegment>(origin, V[0]);
s.new_element<LineSegment>(origin, V0p);
}
}
\ No newline at end of file
#ifndef OERSTED_DISTRIBUTEDWINDINGSTATOR_H
#define OERSTED_DISTRIBUTEDWINDINGSTATOR_H
#include <cstddef>
#include <cmath>
#include "ModelTemplate.h"
#include "Sketch.hpp"
class DistributedWindingStator {
class DistributedWindingStator : public ModelTemplate {
public:
void add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin, size_t Nt);
void add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin) override;
size_t Teeth;
size_t TotalTeeth;
size_t ModeledTeeth;
double_t InnerRadius;
double_t ToothFaceThickness;
......@@ -19,10 +17,6 @@ public:
double_t SlotOpening;
double_t SlotWidth;
std::array<std::shared_ptr<Vertex>,12> V;
std::array<std::shared_ptr<LineSegment>,7> L;
std::array<std::shared_ptr<CircularArc>,5> C;
};
#endif //OERSTED_DISTRIBUTEDWINDINGSTATOR_H
#ifndef OERSTED_MODELTEMPLATE_H
#define OERSTED_MODELTEMPLATE_H
#include <cstddef>
#include <cmath>
#include "Sketch.hpp"
class ModelTemplate {
public:
virtual void add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin) = 0;
bool Convexify{false};
std::vector<std::shared_ptr<Vertex>> V;
std::vector<std::shared_ptr<LineSegment>> L;
std::vector<std::shared_ptr<CircularArc>> C;
};
#endif //OERSTED_MODELTEMPLATE_H
#include "SynchronousReluctanceRotor.h"
void SynchronousReluctanceRotor::add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin) {
// Dimensions are approximate, sketch.solve() + constraints will impose real values
double_t ri = InnerRadius;
double_t ro = OuterRadius;
double_t Np = Poles;
double_t Nb = RadialBridgeThickness.size();
double_t a180p = M_PI / Np;
std::vector<double_t> rr, drr;
std::vector<double_t> aa, dra;
rr.push_back(ro - RadialThickness[0]);
drr.push_back(RadialBridgeThickness[0]);
aa.push_back(a180p - M_PI * AngularThickness[0] / 180.0);
dra.push_back(AngularBridgeThickness[0]);
for (size_t i = 1; i!= RadialThickness.size(); ++i) {
rr.push_back(rr[i-1] - RadialThickness[i]);
drr.push_back(RadialBridgeThickness[i/2]);
aa.push_back(aa[i-1] - M_PI * AngularThickness[i] / 180.0);
dra.push_back(AngularBridgeThickness[i/2]);
}
std::vector<double_t> xr, yr, xa, ya;
for (size_t i = 0; i != rr.size(); ++i) {
xr.push_back(rr[i] * cos(a180p) + drr[i] * sin(a180p));
yr.push_back(rr[i] * sin(a180p) - drr[i] * cos(a180p));
xa.push_back((ro - dra[i]) * cos(aa[i]));
ya.push_back((ro - dra[i]) * sin(aa[i]));
}
// Construct geometry
V.resize(4);
V[0] = s.new_element<Vertex>(ri,0.0);
V[1] = s.new_element<Vertex>(ro,0.0);
V[2] = s.new_element<Vertex>(ri * cos(M_PI / Np), ri * sin(M_PI / Np));
V[3] = s.new_element<Vertex>(ro * cos(M_PI / Np), ro * sin(M_PI / Np));
L.resize(2);
L[0] = s.new_element<LineSegment>(V[0],V[1]);
L[1] = s.new_element<LineSegment>(V[2],V[3],true);
C.resize(2);
C[0] = s.new_element<CircularArc>(V[0],V[2],origin,ri);
C[1] = s.new_element<CircularArc>(V[1],V[3],origin,ro);
for (size_t i = 0; i != Nb; ++i) {
size_t j = 2 * i;
auto v0 = s.new_element<Vertex>(xr[j+1],yr[j+1]);
auto v1 = s.new_element<Vertex>(xr[j],yr[j]);
auto v2 = s.new_element<Vertex>(xa[j+1],ya[j+1]);
auto v3 = s.new_element<Vertex>(xa[j],ya[j]);
auto f0 = s.new_element<Fixation>(v0);
auto f1 = s.new_element<Fixation>(v1);
auto f2 = s.new_element<Fixation>(v2);
auto f3 = s.new_element<Fixation>(v3);
auto l0 = s.new_element<LineSegment>(v0,v1);
//auto l1 = s.new_element<LineSegment>(origin,v2); // for construction
//auto l2 = s.new_element<LineSegment>(origin,v3); // for construction
auto c0 = s.new_element<CircularArc>(v2,v3,origin,ro-dra[j]);
}
// Impose constraints
s.new_element<Horizontal>(L[0]);
s.new_element<Radius>(C[0],ri);
s.new_element<Radius>(C[1],ro);
s.new_element<Angle>(L[0],L[1],180.0 / Np);
double_t tol = s.solve();
// Mirror Copy
std::vector<std::shared_ptr<Curve const>> copy_curves{L[0]};
copy_curves.insert(copy_curves.end(),L.begin()+2,L.end());
copy_curves.insert(copy_curves.end(),C.begin(),C.end());
std::shared_ptr<MirrorCopy> mc = s.new_element<MirrorCopy>(copy_curves,L[1],true);
tol = s.solve();
if (Convexify) {
throw;
}
}
\ No newline at end of file
#ifndef OERSTED_SYNCHRONOUSRELUCTANCEROTOR_H
#define OERSTED_SYNCHRONOUSRELUCTANCEROTOR_H
#include "ModelTemplate.h"
class SynchronousReluctanceRotor : public ModelTemplate {
public:
void add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin) override;
size_t Poles;
double_t InnerRadius;
double_t OuterRadius;
std::vector<double_t> AngularBridgeThickness;
std::vector<double_t> RadialBridgeThickness;
std::vector<double_t> AngularThickness;
std::vector<double_t> RadialThickness;
};
#endif //OERSTED_SYNCHRONOUSRELUCTANCEROTOR_H
......@@ -43,7 +43,7 @@ set(SOURCE_FILES
Model\ Templates/test_ModelTemplates.hpp
Model\ Templates/test_DistributedWindingStator.cpp
)
"Model Templates/test_SynchronousReluctanceRotor.cpp")
add_executable(run_tests ${SOURCE_FILES})
......
......@@ -17,23 +17,19 @@ TEST_F(Distributed_Winding_Stator, basic_test) {
dws.SlotWidth = 6.05e-3;
dws.SlotOpening = 1.74e-3;
dws.Teeth = 48;
dws.TotalTeeth = 48;
dws.ModeledTeeth = 6;
dws.Convexify = true; std::cout << "//Mesh creation fails with non-convex domains" << std::endl;
Sketch sketch;
auto origin = sketch.new_element<Vertex>(0.0,0.0);
auto fo = sketch.new_element<Fixation>(origin);
dws.add_to_sketch(sketch,origin,6);
// TODO: Mesh creation fails with non-convex domains
std::shared_ptr V0p = sketch.select_periodic_vertex(dws.V[0],origin,360.0 / 8.0);
sketch.new_element<LineSegment>(origin, dws.V[0]);
sketch.new_element<LineSegment>(origin, V0p);
EXPECT_LE(sketch.solve(), 89e-3 * FLT_EPSILON);
dws.add_to_sketch(sketch,origin);
std::cout << "//TODO: CHECK CONVERGENCE TOLERANCE DURING SKETCH::SOLVE()" << std::endl;
EXPECT_LE(sketch.solve(), 89e-3 * FLT_EPSILON); std::cout << "//TODO: CHECK CONVERGENCE TOLERANCE DURING SKETCH::SOLVE()" << std::endl;
sketch.save_as<SaveMethod::Rasterize>(SAVE_DIR,"Distributed_Winding_Stator");
......
#include "test_ModelTemplates.hpp"
class Synchronous_Reluctance_Rotor : public ::testing::Test {
public:
virtual void SetUp() {
}
};
TEST_F(Synchronous_Reluctance_Rotor, basic_test) {
SynchronousReluctanceRotor srr;
srr.Poles = 8;
srr.InnerRadius = 25.4e-3;
srr.OuterRadius = 89e-3-0.03*25.4e-3;
srr.AngularBridgeThickness = {0.5e-3};
srr.RadialBridgeThickness = {0.5e-3};
srr.RadialThickness = {5.0e-3,5.0e-3};
srr.AngularThickness = {5.0,5.0};
//srr.Convexify = true; std::cout << "//Mesh creation fails with non-convex domains" << std::endl;
Sketch sketch;
auto origin = sketch.new_element<Vertex>(0.0,0.0);
auto fo = sketch.new_element<Fixation>(origin);
srr.add_to_sketch(sketch,origin);
EXPECT_LE(sketch.solve(), 89e-3 * FLT_EPSILON); std::cout << "//TODO: CHECK CONVERGENCE TOLERANCE DURING SKETCH::SOLVE()" << std::endl;
sketch.save_as<SaveMethod::Rasterize>(SAVE_DIR,"Synchronous_Reluctance_Rotor");
EXPECT_TRUE(sketch.build());
/*
Mesh mesh{sketch};
mesh.create();
mesh.MinimumElementQuality = 0.5;
EXPECT_TRUE(mesh.refine());
mesh.save_as(SAVE_DIR,"Distributed_Winding_Stator");
*/
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment