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 File Reference
#include <iostream>
#include <cmath>
#include <cstring>
#include <fstream>
#include <TCanvas.h>
#include <TApplication.h>
#include "Garfield/MediumMagboltz.hh"
#include "Garfield/ComponentElmer.hh"
#include "Garfield/Sensor.hh"
#include "Garfield/ViewField.hh"
#include "Garfield/Plotting.hh"
#include "Garfield/ViewFEMesh.hh"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 25 of file pp.cc.

25 {
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 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