Commit 2704ddd8 authored by Pries, Jason's avatar Pries, Jason

Add template for Distributed Winding Stator

TODO: Mesh creation fails with non-convex domains
parent dca2ca2b
......@@ -20,6 +20,7 @@ include_directories(./src/Elements/include/)
include_directories(./src/Matrix/include/)
include_directories(./src/Materials/include/)
include_directories(./src/Physics/include/)
include_directories(./src/Model\ Templates/include/)
add_subdirectory(./src/)
......
......@@ -5,7 +5,7 @@ include_directories(./Elements/)
include_directories(./Matrix/)
include_directories(./Materials/)
include_directories(./Physics/)
include_directories(./Model\ Templates/)
add_subdirectory(./Sketch/)
add_subdirectory(./Mesh/)
......@@ -13,4 +13,5 @@ add_subdirectory(./Quadrature/)
add_subdirectory(./Elements/)
add_subdirectory(./Matrix/)
add_subdirectory(./Materials/)
add_subdirectory(./Physics/)
\ No newline at end of file
add_subdirectory(./Physics/)
add_subdirectory(./Model\ Templates/)
\ No newline at end of file
project(Oersted_Model_Templates)
set(SOURCE_FILES
./include/ModelTemplates.hpp
./src/DistributedWindingStator.h ./src/DistributedWindingStator.cpp
)
add_library(model_templates SHARED ${SOURCE_FILES})
target_link_libraries(model_templates)
\ No newline at end of file
#ifndef OERSTED_MODELTEMPLATES_H
#define OERSTED_MODELTEMPLATES_H
#include "../src/DistributedWindingStator.h"
#endif //OERSTED_MODELTEMPLATES_H
#include "DistributedWindingStator.h"
void DistributedWindingStator::add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin, size_t Nt) {
// Dimensions are approximate, sketch.solve() + constraints will impose real values
double_t at = M_PI / Teeth;
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 rso = ri + ToothFaceThickness;
double_t rf = SlotWidth / 2.0;
double_t af = at - M_PI_2;
// Construct geometry
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));
V[3] = s.new_element<Vertex>(rb * cos(at), rb * sin(at));
V[4] = s.new_element<Vertex>(rof * cos(at), rof * sin(at));
V[5] = s.new_element<Vertex>(rif * cos(at), rif * sin(at));
V[6] = s.new_element<Vertex>(rso * cos(at), rso * sin(at));
V[7] = s.new_element<Vertex>(ri * cos(at), ri * sin(at));
V[8] = s.new_element<Vertex>(ri * cos(aso), ri * sin(aso));
V[9] = s.new_element<Vertex>(rso * cos(aso), rso * sin(aso));
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[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
L[3] = s.new_element<LineSegment>(V[7],V[6],true); // for construction
L[4] = s.new_element<LineSegment>(V[8],V[9]);
L[5] = s.new_element<LineSegment>(V[9],V[6]);
L[6] = s.new_element<LineSegment>(V[10],V[11]);
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);
C[3] = s.new_element<CircularArc>(V[11],V[3],V[4],rf);
C[4] = s.new_element<CircularArc>(V[9],V[10],V[5],rf);
// Impose constraints
s.new_element<Horizontal>(L[0]);
s.new_element<Length>(L[1], BackironThickness);
s.new_element<Length>(L[2], SlotDepth);
s.new_element<Length>(L[3], ToothFaceThickness);
s.new_element<Length>(L[4], ToothFaceThickness);
s.new_element<Radius>(C[0], InnerRadius);
s.new_element<Radius>(C[3], SlotWidth / 2.0);
s.new_element<Radius>(C[4], SlotWidth / 2.0);
s.new_element<Tangency>(C[3],L[6]);
s.new_element<Tangency>(C[4],L[6]);
s.new_element<Coincident<LineSegment>>(origin, L[1]);
s.new_element<Coincident<LineSegment>>(origin, L[2]);
s.new_element<Coincident<LineSegment>>(origin, L[3]);
s.new_element<Distance<LineSegment>>(L[3],L[4],SlotOpening / 2.0);
at = 180.0 / Teeth;
s.new_element<Angle>(L[0],L[1],at);
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()+4,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();
// 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);
}
\ No newline at end of file
#ifndef OERSTED_DISTRIBUTEDWINDINGSTATOR_H
#define OERSTED_DISTRIBUTEDWINDINGSTATOR_H
#include <cstddef>
#include <cmath>
#include "Sketch.hpp"
class DistributedWindingStator {
public:
void add_to_sketch(Sketch &s, std::shared_ptr<Vertex> origin, size_t Nt);
size_t Teeth;
double_t InnerRadius;
double_t ToothFaceThickness;
double_t SlotDepth;
double_t BackironThickness;
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
......@@ -20,7 +20,7 @@ set(SOURCE_FILES
./src/HomogeneousForcing.cpp ./src/HomogeneousForcing.h
./src/FunctionArguments.cpp ./src/FunctionArguments.h
./src/FiniteElementMeshInterface.cpp ./src/FiniteElementMeshInterface.h
src/SpatialForcing.cpp src/SpatialForcing.h)
./src/SpatialForcing.cpp ./src/SpatialForcing.h)
add_library(physics SHARED ${SOURCE_FILES})
......
......@@ -3,7 +3,7 @@
#include "Rotation.h"
RotateCopy::RotateCopy(std::vector<std::shared_ptr<Curve const>> input, std::shared_ptr<Vertex const> center, double angle, size_t copies, bool remove_internal) {
// Creates rotated copies of the input curves about an vertex
// Creates rotated copies of the input curves about a vertex
// TODO: Check for complete elimination of leading/lagging curves
// Assign properties
......
......@@ -39,8 +39,12 @@ set(SOURCE_FILES
UseCases/Use_Cases.hpp
UseCases/Stator_Use_Cases.cpp
UseCases/Rotor_Use_Cases.cpp)
UseCases/Rotor_Use_Cases.cpp
Model\ Templates/test_ModelTemplates.hpp
Model\ Templates/test_DistributedWindingStator.cpp
)
add_executable(run_tests ${SOURCE_FILES})
target_link_libraries(run_tests gtest gtest_main sketch elements mesh materials quadrature physics stdc++fs)
\ No newline at end of file
target_link_libraries(run_tests gtest gtest_main sketch elements mesh materials quadrature physics model_templates stdc++fs)
\ No newline at end of file
......@@ -1171,7 +1171,8 @@ TEST_F(Salient_Pole_Synchrel, Test) {
// Solve
Oe::VectorXd v_prev;
msph->assemble();
for (size_t iter = 0; iter != position->size() / 32; ++iter) {
size_t step = 2;
for (size_t iter = 0; iter != position->size() / step; ++iter) {
auto solution = msph->new_solution(); // TODO: What about warm start using old initial condition?
if (iter > 1)
solution->v = v_prev;
......@@ -1191,7 +1192,7 @@ TEST_F(Salient_Pole_Synchrel, Test) {
fem->write_vector(Bx, By, SAVE_DIR, std::string("salient_pole_synchrel_B_") + std::to_string(iter));
// Increment Position
*position += 32;
*position += step;
//t += 32 * dt;
//fargs["t"] = t;
......
#include "test_ModelTemplates.hpp"
class Distributed_Winding_Stator : public ::testing::Test {
public:
virtual void SetUp() {
}
};
TEST_F(Distributed_Winding_Stator, basic_test) {
DistributedWindingStator dws;
dws.InnerRadius = 89e-3;
dws.ToothFaceThickness = 0.75e-3;
dws.SlotDepth = 17.4e-3;
dws.BackironThickness = 16.8e-3;
dws.SlotWidth = 6.05e-3;
dws.SlotOpening = 1.74e-3;
dws.Teeth = 48;
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);
std::cout << "//TODO: CHECK CONVERGENCE TOLERANCE DURING SKETCH::SOLVE()" << std::endl;
sketch.save_as<SaveMethod::Rasterize>(SAVE_DIR,"Distributed_Winding_Stator");
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