I use ComponentConstant to create a uniform electric field along the z direction and us ViewField for visualization to ensure that I have established the uniform electric field.But the view result is blank.How can I visualize the uniform electric field?
This is my code.
int main(int argc, char *argv[])
{
TApplication app("app", &argc, argv);
// Set gas
MediumMagboltz gas;
gas.SetTemperature(293.15);
gas.SetPressure(760.);
gas.SetComposition("Ar", 0.94, "CO2", 0.03, "H2O", 0.03, "O2", 20.9, "N2", 78.1);
gas.Initialise(true); // prepares the table of microscopic scattering rates
gas.LoadGasFile("gas_293_1atm_10-100000nE20.gas");
const string ionpath = std::getenv("GARFIELD_INSTALL");
gas.LoadIonMobility(ionpath + "/share/Garfield/Data/IonMobility_Ar+_Ar.txt");
ComponentConstant cmp;
constexpr double xlength = 10.; // cm
constexpr double ylength = 10.;
constexpr double zlength = 10.;
cmp.SetArea(0., 0., 0., xlength, ylength, zlength);
cmp.SetMedium(&gas);
cmp.SetElectricField(0., 0., 1000.);
ViewField fieldView;
constexpr bool plotField = true;
if (plotField)
{
fieldView.SetComponent(&cmp);
fieldView.SetPlane(0, -1, 0, 0, 0, 0); //viewing plane (xz plane).
fieldView.SetArea(0., 0, 0, xlength, ylength, zlength); //plot limits
TCanvas *cf = new TCanvas("cf", "", 600, 600);
cf->SetLeftMargin(0.16);
fieldView.SetCanvas(cf);
fieldView.PlotContour("e");
}
app.Run(true);
}
This is the result.
Looking forward to your reply, thank you very much!