Commit 7def057d authored by Heinrich Schindler's avatar Heinrich Schindler
Browse files

Merge branch 'ansys121' into 'master'

Add Ansys121 example

See merge request !247
parents 238cf495 ad941614
Pipeline #3158157 passed with stage
in 4 minutes and 56 seconds
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(Ansys121)
if(NOT TARGET Garfield::Garfield)
find_package(Garfield REQUIRED)
endif()
# ---Build executable------------------------------------------------------------
add_executable(strip strip.C)
target_link_libraries(strip Garfield::Garfield)
# ---Copy all files locally to the build directory-------------------------------
foreach(_file ELIST.lis MPLIST.lis NLIST.lis PRNSOL.lis)
configure_file(fieldmaps/strip/${_file} ${CMAKE_CURRENT_BINARY_DIR}/fieldmap/${_file} COPYONLY)
endforeach()
This diff is collapsed.
LIST MATERIALS 1 TO 2 BY 1
PROPERTY= ALL
MATERIAL NUMBER 1
TEMP RSVX
0.000000
TEMP PERX
0.1000000E+11
MATERIAL NUMBER 2
TEMP PERX
4.500000
This diff is collapsed.
This diff is collapsed.
FINISH
/CLEAR,START
/PREP7
KEYW,PR_ELMAG,1
KEYW,MAGELC,1
! Disable the p-method solution options.
/PMETH,OFF,1
! Select the quadrilateral as element:
ET,1,PLANE121
! Material properties
MP, PERX, 1, 1e10 ! Metal
MP, RSVX, 1, 0.0
MP, PERX, 2, 4.5 ! Bulk dielectric constant
! Define some dimensions, in microns
halfpitch = 50
thickbulk = 200
halfstrip = 20
thickstrip = 5
BLC4, 0, 0, halfpitch, thickbulk ! Area 1: dielectricum
BLC4, 0, 0, halfstrip, thickstrip ! Area 2: conductor
ASBA, 1, 2, , , KEEP ! Area 1 becomes area 3
AGLUE, ALL ! Glue everything
! Assign material properties
ASEL, S, , , 3 ! Select the dielectricum
AATT, 2 ! Properties of material 2
ASEL, S, , , 2 ! Select the conductor
AATT, 1 ! Properties of material 1
! Set boundary conditions
ASEL, S, , , 2 ! Select the metal
LSLA, S ! Select all its border lines
DL, ALL, 2, VOLT, 1000 ! Set the borders to 1000 V
ASEL, S, , , 3 ! Select the dielectricum
LSLA, S ! Select all its border lines
LSEL, R, LOC, Y, thickbulk ! Sub-select lines at y=thickbulk
DL, ALL, 3, VOLT, 0 ! Set this line to 0 V
ASEL, S, , , 3
LSLA, S
LSEL, R, LOC, X, 0 ! Select the lines at x=0
DL, ALL, 3, SYMM ! Impose a symmetry condition
ASEL, S, , , 3
LSLA, S
LSEL, R, LOC, X, halfpitch ! Idem for y=halfpitch
DL, ALL, 3, SYMM
! Mesh the problem.
LSEL,ALL
ASEL, ALL
MSHKEY,0
SMRT, 3
AMESH, 2,3
! Solve the problem
/SOLU
SOLVE
FINISH
! Visualise the solution
/POST1
/EFACET,1
PLNSOL, VOLT,, 0
! Write the solution to files
/OUTPUT, PRNSOL, lis
PRNSOL
/OUTPUT
/OUTPUT, NLIST, lis
NLIST,,,,COORD
/OUTPUT
/OUTPUT, ELIST, lis
ELIST
/OUTPUT
/OUTPUT, MPLIST, lis
MPLIST
/OUTPUT
#include <iostream>
#include <TApplication.h>
#include <TCanvas.h>
#include "Garfield/ComponentAnsys121.hh"
#include "Garfield/ViewField.hh"
#include "Garfield/ViewFEMesh.hh"
using namespace Garfield;
int main(int argc, char * argv[]) {
TApplication app("app", &argc, argv);
// Load the field map.
ComponentAnsys121 fm;
fm.Initialise("fieldmap/ELIST.lis", "fieldmap/NLIST.lis",
"fieldmap/MPLIST.lis", "fieldmap/PRNSOL.lis", "micron");
fm.EnableMirrorPeriodicityX();
fm.PrintRange();
fm.PrintMaterials();
ViewField fieldView;
fieldView.SetComponent(&fm);
// Set the plot limits in the current viewing plane.
fieldView.SetArea(-0.01, 0., 0.01, 0.02);
fieldView.PlotContour();
ViewFEMesh meshView;
constexpr bool plotMesh = true;
if (plotMesh) {
meshView.SetComponent(&fm);
meshView.SetArea(-0.01, 0., 0.01, 0.02);
meshView.SetFillMeshWithBorders();
meshView.SetFillColor(1, kCyan + 1);
meshView.EnableAxes();
meshView.Plot();
}
app.Run();
}
......@@ -44,12 +44,6 @@ class ComponentAnsys121 : public ComponentFieldMap {
/// Set the limits of the active region along z.
void SetRangeZ(const double zmin, const double zmax);
protected:
void UpdatePeriodicity() override;
double GetElementVolume(const unsigned int i) override;
void GetAspectRatio(const unsigned int i, double& dmin,
double& dmax) override;
};
}
......
......@@ -36,13 +36,6 @@ class ComponentAnsys123 : public ComponentFieldMap {
bool SetWeightingField(std::string prnsol, std::string label);
protected:
// Verify periodicities
void UpdatePeriodicity() override { UpdatePeriodicityCommon(); }
double GetElementVolume(const unsigned int i) override;
void GetAspectRatio(const unsigned int i, double& dmin,
double& dmax) override;
};
}
#endif
......@@ -197,11 +197,9 @@ class ComponentCST : public ComponentFieldMap {
unsigned int& i, unsigned int& j, unsigned int& k) const;
protected:
// Verify periodicities
void UpdatePeriodicity() override;
double GetElementVolume(const unsigned int i) override;
void GetAspectRatio(const unsigned int i, double& dmin,
double& dmax) override;
double GetElementVolume(const size_t i) const override;
void GetAspectRatio(const size_t i,
double& dmin, double& dmax) const override;
/**
* Calculate the index in the vectors m_xlines, m_ylines, m_zlines, which is
......
......@@ -66,13 +66,6 @@ public:
void SetTimeInterval(const double mint, const double maxt,
const double stept);
protected:
void UpdatePeriodicity() override { UpdatePeriodicityCommon(); }
double GetElementVolume(const unsigned int i) override;
void GetAspectRatio(const unsigned int i, double &dmin,
double &dmax) override;
private:
double m_unit = 100.;
bool m_timeset = false;
......
// Copied and modified ComponentAnsys123.hh
#ifndef G_COMPONENT_ELMER_H
#define G_COMPONENT_ELMER_H
......@@ -52,13 +50,6 @@ class ComponentElmer : public ComponentFieldMap {
/// Import a list of voltages to be used as weighting field.
bool SetWeightingField(std::string prnsol, std::string label);
protected:
// Verify periodicities
void UpdatePeriodicity() override { UpdatePeriodicityCommon(); }
double GetElementVolume(const unsigned int i) override;
void GetAspectRatio(const unsigned int i, double& dmin,
double& dmax) override;
};
}
#endif
......@@ -54,13 +54,6 @@ class ComponentElmer2D : public ComponentFieldMap {
void SetRangeZ(const double zmin, const double zmax);
protected:
// Verify periodicities
void UpdatePeriodicity() override;
double GetElementVolume(const unsigned int i) override;
void GetAspectRatio(const unsigned int i, double& dmin,
double& dmax) override;
};
}
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -1153,13 +1153,8 @@ int ComponentCST::Index2Element(const unsigned int i, const unsigned int j,
return i + j * (m_nx - 1) + k * (m_nx - 1) * (m_ny - 1);
}
void ComponentCST::UpdatePeriodicity() {
UpdatePeriodicity2d();
UpdatePeriodicityCommon();
}
void ComponentCST::GetAspectRatio(const unsigned int element, double& dmin,
double& dmax) {
void ComponentCST::GetAspectRatio(const size_t element, double& dmin,
double& dmax) const {
if (element >= m_nElements) {
dmin = dmax = 0.;
return;
......@@ -1173,7 +1168,7 @@ void ComponentCST::GetAspectRatio(const unsigned int element, double& dmin,
dmax = std::max({dx, dy, dz});
}
double ComponentCST::GetElementVolume(const unsigned int element) {
double ComponentCST::GetElementVolume(const size_t element) const {
if (element >= m_nElements) return 0.;
unsigned int i, j, k;
Element2Index(element, i, j, k);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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