Cleaned up ANSTO code to merge with sinqdev.sics

This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c
Conflicts:
	.gitignore
	SICSmain.c
	asynnet.c
	confvirtualmot.c
	counter.c
	devexec.c
	drive.c
	event.h
	exebuf.c
	exeman.c
	histmem.c
	interface.h
	motor.c
	motorlist.c
	motorsec.c
	multicounter.c
	napi.c
	napi.h
	napi4.c
	network.c
	nwatch.c
	nxscript.c
	nxxml.c
	nxxml.h
	ofac.c
	reflist.c
	scan.c
	sicshipadaba.c
	sicsobj.c
	site_ansto/docs/Copyright.txt
	site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl
	site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl
	statusfile.c
	tasdrive.c
	tasub.c
	tasub.h
	tasublib.c
	tasublib.h
This commit is contained in:
Ferdi Franceschini
2015-04-23 20:49:26 +10:00
parent c650788a2c
commit 10d29d597c
1336 changed files with 9430 additions and 226646 deletions

View File

@@ -40,21 +40,13 @@ double KtoEnergy(double k)
}
/*-------------------------------------------------------------------*/
static double calcCurvature(double B1, double B2, double B3, double theta, double energy, int ori, int focusfn)
static double calcCurvature(double B1, double B2, double theta, int ori)
{
assert(ori == VERT || ori == HOR);
if (focusfn == ENERGY_FN) {
if (ori == VERT) {
return B1 + B2 * energy;
} else {
return B1 + B2 * pow(B3, energy);
}
if (ori == VERT) {
return B1 + B2 / Sind(ABS(theta));
} else {
if (ori == VERT) {
return B1 + B2 / Sind(ABS(theta));
} else {
return B1 + B2 * Sind(ABS(theta));
}
return B1 + B2 * Sind(ABS(theta));
}
}
@@ -74,15 +66,15 @@ int maCalcTwoTheta(maCrystal data, double k, double *two_theta)
}
/*--------------------------------------------------------------------*/
double maCalcVerticalCurvature(maCrystal data, double two_theta, double energy, int focusfn)
double maCalcVerticalCurvature(maCrystal data, double two_theta)
{
return calcCurvature(data.VB1, data.VB2, 1, two_theta / 2., energy, VERT, focusfn);
return calcCurvature(data.VB1, data.VB2, two_theta / 2., VERT);
}
/*-------------------------------------------------------------------*/
double maCalcHorizontalCurvature(maCrystal data, double two_theta, double energy, int focusfn)
double maCalcHorizontalCurvature(maCrystal data, double two_theta)
{
return calcCurvature(data.HB1, data.HB2, data.HB3, two_theta / 2., energy, HOR, focusfn);
return calcCurvature(data.HB1, data.HB2, two_theta / 2., HOR);
}
/*--------------------------------------------------------------------*/
@@ -192,7 +184,7 @@ double tasAngleBetweenReflections(MATRIX B, tasReflection r1,
chi1 = mat_mul(B, h1);
chi2 = mat_mul(B, h2);
if (chi1 != NULL && chi2 != NULL) {
angle = angleBetween(chi1, chi2);
angle = tasAngleBetween(chi1, chi2);
killVector(chi1);
killVector(chi2);
}
@@ -279,8 +271,9 @@ int makeAuxReflection(MATRIX B, tasReflection r1, tasReflection * r2,
r2->qe.ki = r1.qe.ki;
r2->qe.kf = r1.qe.kf;
theta = calcTheta(r1.qe.ki, r1.qe.kf, r1.angles.sample_two_theta);
om = r1.angles.a3 - theta;
theta = calcTheta(r1.qe.ki, r1.qe.kf,
ss*r1.angles.sample_two_theta);
om = r1.angles.a3 - ss*theta;
om += tasAngleBetweenReflections(B, r1, *r2);
QC = tasReflectionToHC(r2->qe, B);
@@ -297,12 +290,17 @@ int makeAuxReflection(MATRIX B, tasReflection r1, tasReflection * r2,
return TRIANGLENOTCLOSED;
}
r2->angles.sample_two_theta = ss * Acosd(cos2t);
theta = calcTheta(r1.qe.ki, r1.qe.kf, r2->angles.sample_two_theta);
r2->angles.a3 = om + theta;
theta = calcTheta(r1.qe.ki, r1.qe.kf, ss*r2->angles.sample_two_theta);
r2->angles.a3 = om + ss*theta;
r2->angles.a3 = fmod(r2->angles.a3 + ss*180.,360.) - ss*180.;
/*
r2->angles.a3 -= 180.;
if (r2->angles.a3 < -180.) {
r2->angles.a3 += 360.;
}
*/
mat_free(QC);
return 1;
@@ -423,22 +421,16 @@ MATRIX calcPlaneNormalQ(MATRIX UB, tasReflection r1, tasReflection r2)
return planeNormal;
}
/*--------------------------------------------------------------------*/
MATRIX calcTestUB(lattice cell, double om, double sgu, double sgl)
/*--------------------------------------------------------------------
This is shot. The resulting UB is invalid. This needs more throught.
*/
MATRIX calcUBFromAngles(MATRIX B, double om, double sgu, double sgl)
{
MATRIX B, M, N, OM, UB;
MATRIX M, N, OM, UB;
int status;
/*
* create matrices
*/
B = mat_creat(3, 3, ZERO_MATRIX);
status = calculateBMatrix(cell, B);
if (status < 0) {
return NULL;
}
M = mat_creat(3, 3, ZERO_MATRIX);
N = mat_creat(3, 3, ZERO_MATRIX);
OM = mat_creat(3, 3, ZERO_MATRIX);
@@ -476,11 +468,30 @@ MATRIX calcTestUB(lattice cell, double om, double sgu, double sgl)
mat_free(OM);
mat_free(N);
mat_free(M);
mat_free(B);
return UB;
}
/*--------------------------------------------------------------------*/
MATRIX calcTestUB(lattice cell, double om, double sgu, double sgl)
{
MATRIX B, UB;
int status;
/*
* create matrices
*/
B = mat_creat(3, 3, ZERO_MATRIX);
status = calculateBMatrix(cell, B);
if (status < 0) {
return NULL;
}
UB = calcUBFromAngles(B,om,sgu,sgl);
mat_free(B);
return UB;
}
/*--------------------------------------------------------------------*/
MATRIX calcTestNormal(double sgu, double sgl)
{
MATRIX M, N, Z, NORM;
@@ -835,7 +846,7 @@ int calcTasQAngles(MATRIX UB, MATRIX planeNormal, int ss, double a3offset,
angles->a3 += 360.;
}
*/
angles->a3 = fmod(angles->a3 + ss*180.,360.) - ss*180.;
angles->a3 = fmod(angles->a3 + ss*180.,360.) - ss*180.;
killVector(QC);
mat_free(R);