# ViewField() - Error "ComponentVoxel::ElectricField : Field is not available for interpolation"

**URL:** <https://root-forum.cern.ch/t/viewfield-error-componentvoxel-electricfield-field-is-not-available-for-interpolation/34873>\
**Category:** Garfield++\
**Created:** [June 27, 2019, 11:37am UTC](https://root-forum.cern.ch/t/viewfield-error-componentvoxel-electricfield-field-is-not-available-for-interpolation/34873 "2019-06-27T11:37:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kali95](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@Kali95](https://root-forum.cern.ch/u/Kali95)\
**Post date:** [June 27, 2019, 11:37am UTC](https://root-forum.cern.ch/t/viewfield-error-componentvoxel-electricfield-field-is-not-available-for-interpolation/34873/1 "2019-06-27T11:37:30Z")

</div>

Hello,

I wrote a macro to set a magnetic Field in a parallelepiped and do interpolation. I take the values of the magnetic field from a txt file. So, it is convenient to use the ComponentVoxel of garfield. The macro read well the values.

After I wanted to view the magnetic field but it prints the error message “ComponentVoxel::ElectricField : Field is not available for interpolation” many times and I don’t understand why. So, I cannot view the MagneticField.

Here is my code :

```auto
const unsigned int nx=13;
	const unsigned int ny=13;
	const unsigned int nz=251;
	const double xmin=-240;
	const double xmax=240;
	const double ymin=-240;
	const double ymax=240;
	const double zmin=-5000;
	const double zmax=5000;

	const std::string filename = "data_test.txt";
	const std::string format= "XYZ";
	ComponentVoxel *mesh=new ComponentVoxel();
	mesh->SetMesh(nx,ny,nz,xmin,xmax,ymin,ymax,zmin,zmax);
	mesh->LoadMagneticField(filename,format,1,1);
	mesh->EnableInterpolation(true);

	/ ***Viewing the magnetic volume*** /
	TCanvas* c = new TCanvas()
	ViewField* meshView = new ViewField();
	meshView->SetCanvas(c);	
	meshView->SetComponent(mesh);
        meshView->SetPlane(0,0,1,0,0,0);
	meshView->SetArea(xmin, ymin, xmax, ymax);
	meshView->Plot();

```

And attached, you are the data\_test.dat file.  
[data\_test.tar.gz](https://root-forum.cern.ch/uploads/default/original/3X/7/6/765099064294b0f642169b2fc58b526d0ce17489.gz) (1.1 MB)

Thank you in advance,

Kali95

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 11, 2019, 11:37am UTC](https://root-forum.cern.ch/t/viewfield-error-componentvoxel-electricfield-field-is-not-available-for-interpolation/34873/2 "2019-07-11T11:37:35Z")

</div>

Closed on July 11, 2019, 11:37am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
