v1.0.0-rc.91
This commit is contained in:
@@ -18,22 +18,24 @@ TEST_CASE("XtalOptimizer") {
|
||||
|
||||
CrystalLattice latt_i(40,40,80,90,90,90);
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i,1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
xtal_opt.latt = CrystalLattice(40.2,39.4,80.2, 90,91, 89);
|
||||
xtal_opt.geom.BeamX_pxl(1010).BeamY_pxl(995).DetectorDistance_mm(200)
|
||||
.PoniRot1_rad(0.01).PoniRot2_rad(0.02);
|
||||
xtal_opt.crystal_system = gemmi::CrystalSystem::Monoclinic;
|
||||
xtal_opt.crystal_system = gemmi::CrystalSystem::Triclinic;
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
REQUIRE(XtalOptimizer(xtal_opt, spots));
|
||||
@@ -69,15 +71,17 @@ TEST_CASE("XtalOptimizer_NoBeamCenter") {
|
||||
|
||||
CrystalLattice latt_i(40,50,80,90,95,90);
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i,1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
@@ -120,17 +124,18 @@ TEST_CASE("XtalOptimizer_orthorombic") {
|
||||
|
||||
CrystalLattice latt_i(40,50,80,90,90,90);
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i,1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
xtal_opt.latt = CrystalLattice(40.2,49.6,80.3, 90,91, 89);
|
||||
xtal_opt.geom.BeamX_pxl(1005).BeamY_pxl(997).DetectorDistance_mm(200)
|
||||
@@ -158,6 +163,58 @@ TEST_CASE("XtalOptimizer_orthorombic") {
|
||||
CHECK(fabs(uc_o.gamma - 90) < 0.02);
|
||||
}
|
||||
|
||||
TEST_CASE("XtalOptimizer_triclinic") {
|
||||
DiffractionExperiment exp_i;
|
||||
exp_i.IncidentEnergy_keV(WVL_1A_IN_KEV)
|
||||
.BeamX_pxl(1000)
|
||||
.BeamY_pxl(1000)
|
||||
.PoniRot1_rad(0.01)
|
||||
.PoniRot2_rad(0.02)
|
||||
.DetectorDistance_mm(200);
|
||||
|
||||
CrystalLattice latt_i(40,55,120,95,97,100);
|
||||
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001,
|
||||
};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
XtalOptimizerData xtal_opt;
|
||||
xtal_opt.latt = CrystalLattice(40.1,54.9,121, 95,97, 99.5);
|
||||
xtal_opt.geom.BeamX_pxl(997).BeamY_pxl(1005).DetectorDistance_mm(200)
|
||||
.PoniRot1_rad(0.01).PoniRot2_rad(0.02);
|
||||
xtal_opt.crystal_system = gemmi::CrystalSystem::Triclinic;
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
REQUIRE(XtalOptimizer(xtal_opt, spots));
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
std::cout << "XtalOptimizer took " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
|
||||
<< " microseconds" << std::endl;
|
||||
|
||||
auto uc_i = latt_i.GetUnitCell();
|
||||
auto uc_o = xtal_opt.latt.GetUnitCell();
|
||||
|
||||
std::cout << "Beam center: " << xtal_opt.geom.GetBeamX_pxl() << " " << xtal_opt.geom.GetBeamY_pxl() << std::endl;
|
||||
std::cout << "Unit cell: " << uc_o.a << " " << uc_o.b << " " << uc_o.c << std::endl;
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.1);
|
||||
|
||||
CHECK(fabsf(uc_i.a - uc_o.a) < 0.1);
|
||||
CHECK(fabsf(uc_i.b - uc_o.b) < 0.1);
|
||||
CHECK(fabsf(uc_i.c - uc_o.c) < 0.5);
|
||||
CHECK(fabsf(uc_i.alpha - uc_o.alpha) < 0.05);
|
||||
CHECK(fabsf(uc_i.beta - uc_o.beta) < 0.05);
|
||||
CHECK(fabsf(uc_i.gamma - uc_o.gamma) < 0.05);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("XtalOptimizer_tetragonal") {
|
||||
DiffractionExperiment exp_i;
|
||||
exp_i.IncidentEnergy_keV(WVL_1A_IN_KEV)
|
||||
@@ -169,15 +226,17 @@ TEST_CASE("XtalOptimizer_tetragonal") {
|
||||
|
||||
CrystalLattice latt_i(40,40,80,90,90,90);
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i,1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
@@ -201,7 +260,7 @@ TEST_CASE("XtalOptimizer_tetragonal") {
|
||||
|
||||
CHECK(fabsf(uc_i.a - uc_o.a) < 0.1);
|
||||
CHECK(fabsf(uc_i.b - uc_o.b) < 0.1);
|
||||
CHECK(fabsf(uc_i.c - uc_o.c) < 0.2);
|
||||
CHECK(fabsf(uc_i.c - uc_o.c) < 0.5);
|
||||
CHECK(fabs(uc_o.alpha - 90) < 0.02);
|
||||
CHECK(fabs(uc_o.beta - 90) < 0.02);
|
||||
CHECK(fabs(uc_o.gamma - 90) < 0.02);
|
||||
@@ -218,15 +277,17 @@ TEST_CASE("XtalOptimizer_hexagonal") {
|
||||
|
||||
CrystalLattice latt_i(40,40,70,90,90,120);
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i,1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
@@ -269,15 +330,17 @@ TEST_CASE("XtalOptimizer_hexagonal_unconstrained") {
|
||||
|
||||
CrystalLattice latt_i(40,40,70,90,90,120);
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i,1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
@@ -323,15 +386,17 @@ TEST_CASE("XtalOptimizer_cubic") {
|
||||
Coord(0, 40 / sqrt(2), 40 / sqrt(2)));
|
||||
auto uc_i = latt_i.GetUnitCell();
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i,1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
@@ -362,15 +427,7 @@ TEST_CASE("XtalOptimizer_cubic") {
|
||||
CHECK(fabs(uc_o.gamma - 90) < 0.02);
|
||||
}
|
||||
|
||||
TEST_CASE("XtalOptimizer_cubic_I") {
|
||||
// Conventional cubic (take as I-conventional basis): a=b=c=50, orthogonal
|
||||
const float a0 = 50.f;
|
||||
const float expected_len = a0 * std::sqrt(3.f) * 0.5f; // a*sqrt(3)/2
|
||||
const float expected_angle = 109.4712206f; // arccos(-1/3) in degrees
|
||||
|
||||
CrystalLattice latt_i(expected_len, expected_len, expected_len,
|
||||
expected_angle, expected_angle, expected_angle);
|
||||
|
||||
TEST_CASE("XtalOptimizer_monoclinic") {
|
||||
DiffractionExperiment exp_i;
|
||||
exp_i.IncidentEnergy_keV(WVL_1A_IN_KEV)
|
||||
.BeamX_pxl(1000)
|
||||
@@ -379,45 +436,48 @@ TEST_CASE("XtalOptimizer_cubic_I") {
|
||||
.PoniRot2_rad(0.02)
|
||||
.DetectorDistance_mm(200);
|
||||
|
||||
CrystalLattice latt_i(50,60,70,90,96,90);
|
||||
|
||||
auto uc_i = latt_i.GetUnitCell();
|
||||
|
||||
auto pred = CalcBraggPredictions(exp_i, latt_i, 1.5, 0.001);
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.001
|
||||
};
|
||||
BraggPrediction prediction;
|
||||
auto count = prediction.Calc(exp_i, latt_i, prediction_settings);
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
|
||||
for (const auto &[ang, refl]: pred) {
|
||||
spots.push_back(SpotToSave{
|
||||
refl.predicted_x,
|
||||
refl.predicted_y
|
||||
});
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto refl = prediction.GetReflections().at(i);
|
||||
spots.push_back(SpotToSave{refl.predicted_x, refl.predicted_y});
|
||||
}
|
||||
|
||||
XtalOptimizerData xtal_opt;
|
||||
xtal_opt.latt = latt_i;
|
||||
xtal_opt.latt = CrystalLattice(49.5, 60.5, 69.8, 90, 95.5, 90);
|
||||
xtal_opt.geom.BeamX_pxl(1007).BeamY_pxl(990).DetectorDistance_mm(200)
|
||||
.PoniRot1_rad(0.01).PoniRot2_rad(0.02);
|
||||
xtal_opt.crystal_system = gemmi::CrystalSystem::Cubic;
|
||||
xtal_opt.centering = 'I';
|
||||
|
||||
xtal_opt.crystal_system = gemmi::CrystalSystem::Monoclinic;
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
REQUIRE(XtalOptimizer(xtal_opt, spots));
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
std::cout << "XtalOptimizer took " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
|
||||
<< " microseconds" << std::endl;
|
||||
<< " microseconds" << std::endl;
|
||||
|
||||
auto uc_o = xtal_opt.latt.GetUnitCell();
|
||||
|
||||
std::cout << "Beam center: " << xtal_opt.geom.GetBeamX_pxl() << " " << xtal_opt.geom.GetBeamY_pxl() << std::endl;
|
||||
std::cout << "Unit cell: " << uc_o.a << " " << uc_o.b << " " << uc_o.c << std::endl;
|
||||
std::cout << "Unit cell: " << uc_o.a << " " << uc_o.b << " " << uc_o.c << " " << uc_o.alpha << " " << uc_o.beta << " " << uc_o.gamma << std::endl;
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.1);
|
||||
|
||||
CHECK(fabsf(uc_i.a - uc_o.a) < 0.1);
|
||||
CHECK(fabsf(uc_i.b - uc_o.b) < 0.1);
|
||||
CHECK(fabsf(uc_i.c - uc_o.c) < 0.2);
|
||||
CHECK(fabs(uc_o.alpha - expected_angle) < 0.02);
|
||||
CHECK(fabs(uc_o.beta - expected_angle) < 0.02);
|
||||
CHECK(fabs(uc_o.gamma - expected_angle) < 0.02);
|
||||
CHECK(fabs(uc_o.alpha - 90) < 0.02);
|
||||
CHECK(fabs(uc_o.beta - uc_i.beta) < 0.02);
|
||||
CHECK(fabs(uc_o.gamma - 90) < 0.02);
|
||||
}
|
||||
|
||||
TEST_CASE("LatticeToRodrigues") {
|
||||
|
||||
Reference in New Issue
Block a user