Пример #1
0
void Tarrec::Allocator(void)
{
//
// Now populate lattice with homogeneous, isotropic composition.
	int curSize = nx * ny;
	ixyz.Dimension(curSize, 3);
//
	minJx = minJy = minJz = 1;
	maxJx = nx;
	maxJy = ny;
	maxJz = nz;
//
	nat0 = 0;
	for(int jx=0; jx<nx; ++jx)
	{
		for(int jy=0; jy<ny; ++jy)
		{
			for(int jz=0; jz<nz; ++jz)
			{
				if (nat0 >= curSize)
				{
					ixyz.Extend(nz);
					curSize = ixyz.GetSize(0);
				}
				ixyz.Fill3(nat0, jx+1, jy+1, jz+1);					// Positions are expressed starting from one, not zero 
				int index = GetLinearAddress(nat0);
				Composer(index, 0);
				iocc[index] = true;
				++nat0;
			}
		}
	}
	ixyz.Close(nat0);
}
Пример #2
0
void LoadableTarget::Printer(void)
{
	if (manager->Ioshp())
	{
		FILE *ioshpFile = fopen("target.out", "w");
		if (ioshpFile)
		{
			fprintf(ioshpFile, " >%s %s;", shortDescr.c_str(), longDescr.c_str()); 
			fprintf(ioshpFile, "%10d = NAT", nat0);
			if (shpar)
				fprintf(ioshpFile, ", Diamx = %8.4lf\n", shpar[0]);
			else
				fprintf(ioshpFile, "\n");
			fprintf(ioshpFile, "%8.4lf%8.4lf%8.4lf = alpha_1-3\n", alpha.data[0], alpha.data[1], alpha.data[2]);
			OutVectors(ioshpFile);
			fprintf(ioshpFile, "for dipole 0 0 0\n     JA  IX  IY  IZ ICOMP(x,y,z)\n");
			for(int ja=0; ja<nat0; ++ja)
			{
				fprintf(ioshpFile, "%7d", ja);
				ixyz.PrintLine(ioshpFile, "%4d", ja);
				int index = GetLinearAddress(ja);
				icomp.PrintLine(ioshpFile, "%2d", index);
				if (dfdata && dfdata->IsAllocated())
					fprintf(ioshpFile, "%10.6lf%10.6lf%10.6lf", dfdata->GetBetadf(index), dfdata->GetPhidf(index), dfdata->GetThetadf(index));
				fprintf(ioshpFile, "\n");
			}
			fclose(ioshpFile);
		}
		else
			fprintf(stderr, "Cannot open ioshpFile in AbstractFile::Printer for %s.", shortDescr.c_str());
	}
}
Пример #3
0
void Taranirec::Allocator(void)
{
//
// Now populate lattice:
	int curSize = nx * ny;
	ixyz.Dimension(curSize, 3);
//
	minJx = minJy = minJz = 1;
	maxJx = nx;
	maxJy = ny;
	maxJz = nz;
	nat0 = 0;
	for(int jx=0; jx<nx; ++jx)
	{
		for(int jy=0; jy<ny; ++jy)
		{
			for(int jz=0; jz<nz; ++jz)
			{
				if (nat0 >= curSize)
				{
					ixyz.Extend(nz);
					curSize = ixyz.GetSize(0);
				}
				ixyz.Fill3(nat0, jx+1, jy+1, jz+1);
				int index = GetLinearAddress(nat0);
				icomp.Fill3(index, (short)1, (short)2, (short)3);			// Homogeneous, anisotropic composition:
				iocc[index] = true;
				++nat0;
			}
		}
	}
	ixyz.Close(nat0);
}
Пример #4
0
void Tartet::Allocator(void)
{
	if ((dx.data[0] != onex_) || (dx.data[1] != onex_))
		Errmsg("Fatal", "Tartet", " tartet does not support noncubic lattice");
//
// Determine list of occupied sites.
	int curSize = nx * ny;
	ixyz.Dimension(curSize, 3);

	nat0 = 0;
	for(int i=minJx; i<=maxJx; ++i)
	{
		real x = i + xoff;
// YMAX=largest value of Y which can occur for this X value
// YMIN=smallest value of Y which can occur for this X value
// ZMAX0=largest value of Z which can occur for this X value
		real ymax = (real)( shpar[0] * Sqrt(3./16.) - x / Sqrt(twox_));
		real ymin = (real)(-shpar[0] * Sqrt(3./64.) + x / Sqrt(8.));
		real zmax0 = (real)(3. * shpar[0] / 8. - x * Sqrt(3./8.));
		for(int j=minJy; j<=maxJy; ++j)
		{
			real y = j + yoff;
			if ((y >= ymin) && (y <= ymax))
			{
				real fy = (y - ymin) / (ymax - ymin);
				real zmax = (onex_ - fy) * zmax0;				// ! ZMAX=largest value of Z which can occur for this (X,Y)
				for(int k=minJz; k<=maxJz; ++k)
				{
					real z = k + zoff;
					if (Fabs(z) <= zmax)					// ! Site is occupied:
					{
						if (nat0 >= curSize)
						{
							ixyz.Extend(nz);
							curSize = ixyz.GetSize(0);
						}
						ixyz.Fill3(nat0, i, j, k);
						int index = GetLinearAddress(nat0);
						Composer(index, 0);
						iocc[index] = true;
						++nat0;
					}
				}
			}
		}
	}
	ixyz.Close(nat0);
}
Пример #5
0
void AbstractTarget::OutVectorsAndArrays(FILE *file)
{
	a1.Fprintf(file, "%10.6lf", NULL, " = A_1 vector\n");
	a2.Fprintf(file, "%10.6lf", NULL, " = A_2 vector\n");
	dx.Fprintf(file, "%10.6lf", NULL, " = lattice spacings (d_x,d_y,d_z)/d\n");		
	x0.Fprintf(file, "%10.6lf", NULL, " = lattice offset x0(1-3) = (x_TF,y_TF,z_TF)/d ");		 
	fprintf(file, "for dipole 0 0 0\n     JA  IX  IY  IZ ICOMP(x,y,z)\n");
	for(int ja=0; ja<nat0; ++ja)
	{
		fprintf(file, "%7d", ja);
		ixyz.PrintLine(file, "%4d", ja);
		int index = GetLinearAddress(ja);
		icomp.PrintLine(file, "%2d", index);
		fprintf(file, " %d\n", index);
	}
}
Пример #6
0
void LoadableTarget::Allocator(void)
{
	FILE *idvshpFile = fopen(cflshp, "r");
	if (idvshpFile)
	{
		int i, ja;
		char Buffer[256];
		for(i=0; i<7; ++i)
		{
			fgets(Buffer, 255, idvshpFile);
			if (i == 1)
			{
				sscanf(Buffer, "%d", &nat0);
				ixyz.Dimension(nat0, 3);
			}
		}
//
		Line::nx = nx;
		Line::ny = ny;
		Line::nz = nz;
		vector<Line *> *temp = new vector<Line *>;
		for(i=0; i<nat0; ++i)
		{
			fgets(Buffer, 255, idvshpFile);
			Line *line = new Line;
			sscanf(Buffer, "%d%d%d%d%d%d%d", &ja, &line->ix, &line->iy, &line->iz, &line->icc1, &line->icc2, &line->icc3);
			temp->push_back(line);
		}
		fclose(idvshpFile);
//
		std::sort(temp->begin(), temp->end(), sortPredicate);
		for(i=0; i<nat0; ++i)
		{
			Line *line = temp->at(i);
			ixyz.Fill3(i, line->ix, line->iy, line->iz);
			int index = GetLinearAddress(i);
			icomp.Fill3(index, line->icc1, line->icc2, line->icc3);
			iocc[index] = true;
		}
		if (temp)
			for_each(temp->begin(), temp->end(), DeleteTableElement());
		CleanDelete(temp);
	}
	else
		Wrimsg("From File::Allocator", "Error: Cannot open shape file");
}
Пример #7
0
void Target_Octahedron::Allocator(void)
{
//
// Current version of TARPLATONIC is restricted to cubic lattices
	if ((dx.data[0] != onex_) || (dx.data[1] != onex_))
		Errmsg("Fatal", shortDescr.c_str(), " TargetOctahedron does not support noncubic lattice");
//
	int nlong = (int)shpar[0];
	real nlongHalf = nlong / (real)2.;
//
	int curSize = nx * ny;
	ixyz.Dimension(curSize, 3);
//
	nat0 = 0;
	for(int jx=minJx; jx<=maxJx; ++jx)
	{
		real x = (real)jx - nlongHalf;
		for(int jy=minJy; jy<=maxJy; ++jy)
		{
			real y = (real)jy - nlongHalf;
			for(int jz=minJz; jz<=maxJz; ++jz)
			{
				real z = (real)jz - nlongHalf;
				if (Check(x, y, z))
				{
					if (nat0 >= curSize)
					{
						ixyz.Extend(nz);
						curSize = ixyz.GetSize(0);
					}
					ixyz.Fill3(nat0, jx, jy, jz);
					int index = GetLinearAddress(nat0);
					Composer(index, 0);
					iocc[index] = true;
					++nat0;
				}
			}
		}
	}
	ixyz.Close(nat0);
}
Пример #8
0
void AbstractTarget::Debug(const char *fileName)
{
	FILE *fx = fopen(fileName, "w");
	if (!fx)
	{
		Wrimsg("AbstractTarget::Debug", "Cannot open Debug.txt file fx\n");
		return;
	}
	fprintf(fx, "Nat0 = %d, nat = %d, nx,ny,nz = %d %d %d\n", nat0, nat, nx, ny, nz);
	fprintf(fx, "Minmax = %d %d %d %d %d %d\n", minJx, maxJx, minJy, maxJy, minJz, maxJz);
	x0.Fprintf(fx, "%lf");
	fprintf(fx, "\n");
    for(int ii=0; ii<nat0; ++ii)
	{
		fprintf(fx, "%5d", ii);
		ixyz.PrintLine(fx, "%5d", ii);
		int jj = GetLinearAddress(ii);
		fprintf(fx, "%5d", iocc[jj]);
		icomp.PrintLine(fx, "%5d", jj);
		fprintf(fx, " %d\n", jj);
	}
	fclose(fx);
}
Пример #9
0
void Tarcyl::Allocator(void) // A=cylinder length/d, B=cylinder diameter/d
{
	int jlo, jhi;
	int curSize  = nx * ny;
	ixyz.Dimension(curSize, 3);
	real r2 = (real)0.25 * shpar[1] * shpar[1];
//
	switch((int)shpar[2])
	{
		case 1:
			jlo = maxJx;
			jhi = minJx;
			nat0 = 0;
			for(int jx=minJx; jx<=maxJx; ++jx)
			{
				real rx2 = twox_ * Fabs(jx * dx.data[0] - xcm);
				if (rx2 <= shpar[0])
				{
					for(int jy=minJy; jy<=maxJy; ++jy)
					{
						real ry2 = jy * dx.data[1] - ycm;
						ry2 = ry2 * ry2;
						for(int jz=minJz; jz<=maxJz; ++jz)
						{
							real rz2 = jz * dx.data[2] - zcm;
							rz2 = rz2 * rz2;
							if (ry2 + rz2 <= r2)
							{
								if (nat0 >= curSize)
								{
									ixyz.Extend(nz);
									curSize = ixyz.GetSize(0);
								}
								ixyz.Fill3(nat0, jx, jy, jz);
								int index = GetLinearAddress(nat0);
								Composer(index, 0);
								iocc[index] = true;
								if (jx < jlo) 
									jlo = jx;
								if (jx > jhi) 
									jhi = jx;
								++nat0;
							}
						}
					}
				}
			}
			break;

		case 2:
			jlo = maxJy;
			jhi = minJy;
			nat0 = 0;
			for(int jx=minJx; jx<=maxJx; ++jx)
			{
				real rx2 = jx * dx.data[0] - xcm;
				rx2 = rx2 * rx2;
				for(int jy=minJy; jy<=maxJy; ++jy)
				{
					real ry2 = twox_ * Fabs(jy * dx.data[1] - ycm);
					if (ry2 <= shpar[0])
					{
						for(int jz=minJz; jz<=maxJz; ++jz)
						{
							real rz2 = jz * dx.data[2] - zcm;
							rz2 = rz2 * rz2;
							if (rx2 + rz2 <= r2)
							{
								if (nat0 >= curSize)
								{
									ixyz.Extend(nz);
									curSize = ixyz.GetSize(0);
								}
								ixyz.Fill3(nat0, jx, jy, jz);
								int index = GetLinearAddress(nat0);
								Composer(index, 0);
								iocc[index] = true;
								if (jy < jlo)
									jlo = jy;
								if (jy > jhi) 
									jhi = jy;
								++nat0;
							}
						}
					}
				}
			}
			break;

		case 3:
			jlo = maxJz;
			jhi = minJz;
			nat0 = 0;
			for(int jx=minJx; jx<=maxJx; ++jx)
			{
				real rx2 = jx * dx.data[0] - xcm;
				rx2 = rx2 * rx2;
				for(int jy=minJy; jy<=maxJy; ++jy)
				{
					real ry2 = jy * dx.data[1] - ycm;
					ry2 = ry2 * ry2;
					if (rx2 + ry2 <= r2)
					{
						for(int jz=minJz; jz<=maxJz; ++jz)
						{
							real rz2 = twox_ * Fabs(jz * dx.data[2] - zcm);
							if (rz2 <= shpar[0])
							{
								if (nat0 >= curSize)
								{
									ixyz.Extend(nz);
									curSize = ixyz.GetSize(0);
								}
								ixyz.Fill3(nat0, jx, jy, jz);
								int index = GetLinearAddress(nat0);
								Composer(index, 0);
								iocc[index] = true;
								if (jz < jlo) 
									jlo = jz;
								if (jz > jhi) 
									jhi = jz;
			                    ++nat0;
							}
						}
					}
				}
			}
			break;

		default:
			break;
	}
	int nlay = jhi - jlo + 1;
	ixyz.Close(nat0);
//
// NLAY = number of layers in cylinder
// NFAC = number of atoms in slice
	int nfac = nat0 / nlay;
//
// REFF2=effective radius**2 of disk
	real reff2 = (real)nfac / Pi;
//
// ASPR=aspect ratio (length/diameter)
	real aspr = half_ * (real)nlay / Sqrt(reff2);
//
// Description
	sprintf(freeDescr, " Cyl.prism, NAT=%7d NFAC=%4d NLAY=%4d asp.ratio=%lf", nat0, nfac, nlay, aspr);
}
Пример #10
0
Файл: mylib.c Проект: 8l/R3X
uint32_t myfunc(void) {
	printf("getting argument 1 (STRING): %s\n", (char*)GetLinearAddress(MyCPU, GetArgument(MyCPU, 1,1)));
	printf("returning 666\n");
	return 666;
}