Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
pp.cc
Go to the documentation of this file.
1/**
2 * parallel_plate.cc
3 * General program flow based on example code from the Garfield++ website.
4 *
5 * Demonstrates the importing of a parallel-plate capacitor field map
6 * from Gmsh/Elmer into Garfield++.
7 *
8*/
9#include <iostream>
10#include <cmath>
11#include <cstring>
12#include <fstream>
13#include <TCanvas.h>
14#include <TApplication.h>
15
18#include "Garfield/Sensor.hh"
19#include "Garfield/ViewField.hh"
20#include "Garfield/Plotting.hh"
22
23using namespace Garfield;
24
25int main(int argc, char * argv[]) {
26
27 TApplication app("app", &argc, argv);
28
29 // Set relevant geometric parameters.
30 const double ext_x = 1.0; // external box x-width
31 const double ext_y = 1.0; // external box y-width
32 const double ext_z = 1.0; // external box z-width
33
34 // Create a main canvas.
35 TCanvas * c1 = new TCanvas();
36
37 // Define the medium (Ar/CO2 70:30).
38 MediumMagboltz gas("ar", 70., "co2", 30.);
39 // Set the temperature [K] ad pressure [Torr].
40 gas.SetTemperature(293.15);
41 gas.SetPressure(740.);
42
43 // Import an Elmer-created parallel plate field map.
44 ComponentElmer elm("parallel_plate/mesh.header",
45 "parallel_plate/mesh.elements",
46 "parallel_plate/mesh.nodes",
47 "parallel_plate/dielectrics.dat",
48 "parallel_plate/parallel_plate.result", "cm");
49 elm.SetGas(&gas);
50
51 // Set up a sensor object.
52 Sensor sensor;
53 sensor.AddComponent(&elm);
54 sensor.SetArea(-ext_x,-ext_y,-ext_z,ext_x,ext_y,ext_z);
55
56 // Set up the object for field visualization.
57 ViewField vf;
58 vf.SetSensor(&sensor);
59 vf.SetCanvas(c1);
60 vf.SetArea(-ext_x,-ext_y,ext_x,ext_y);
62 vf.SetNumberOfSamples2d(30,30);
63 vf.SetPlane(0,-1,0,0,0,0);
64
65 // Set up the object for FE mesh visualization.
66 ViewFEMesh vFE;
67 vFE.SetCanvas(c1);
68 vFE.SetComponent(&elm);
69 vFE.SetPlane(0,0,-1,0,0,0);
70 vFE.SetFillMesh(true);
71 vFE.SetColor(1,kBlue);
72
73 // Create plots.
74 vFE.SetArea(-ext_x,-ext_z,-ext_z,ext_x,ext_z,ext_z);
75 vf.PlotContour("v");
76 //vFE.Plot();
77
78 app.Run();
79
80 return 0;
81}
Component for importing field maps computed by Elmer.
void SetTemperature(const double t)
Set the temperature [K].
Definition Medium.cc:72
void SetPressure(const double p)
Definition Medium.cc:82
void AddComponent(Component *comp)
Add a component.
Definition Sensor.cc:355
bool SetArea(const bool verbose=false)
Set the user area to the default.
Definition Sensor.cc:187
void SetCanvas(TPad *pad)
Set the canvas to be painted on.
Definition ViewBase.hh:28
void SetArea(const double xmin, const double ymin, const double xmax, const double ymax)
Definition ViewBase.cc:109
virtual void SetPlane(const double fx, const double fy, const double fz, const double x0, const double y0, const double z0)
Definition ViewBase.cc:142
Draw the mesh of a field-map component.
Definition ViewFEMesh.hh:22
void SetPlane(const double fx, const double fy, const double fz, const double x0, const double y0, const double z0) override
void SetComponent(ComponentFieldMap *cmp)
Set the component from which to retrieve the mesh and field.
Definition ViewFEMesh.cc:49
void SetColor(int matID, int colorID)
Definition ViewFEMesh.hh:58
void SetFillMesh(const bool f)
Element fill switch; 2D only, set false for wireframe mesh.
Definition ViewFEMesh.hh:50
Visualize the potential or electric field of a component or sensor.
Definition ViewField.hh:15
void SetNumberOfSamples2d(const unsigned int nx, const unsigned int ny)
Set the number of points used for drawing 2D functions.
Definition ViewField.cc:123
void PlotContour(const std::string &option="v")
Definition ViewField.cc:129
void SetNumberOfContours(const unsigned int n)
Set the number of contour levels.
Definition ViewField.cc:115
void SetSensor(Sensor *s)
Set the sensor for which to plot the field.
Definition ViewField.cc:73
int main(int argc, char *argv[])
Definition pp.cc:25