Xmipp  v3.23.11-Nereus
Classes | Functions
art_crystal (ART for crystals)
Collaboration diagram for art_crystal (ART for crystals):

Classes

class  CrystalARTRecons
 

Functions

void computeIntegerLattice (const Matrix1D< double > &a, const Matrix1D< double > &b, double a_mag, double b_mag, double ang_a2b_deg, Matrix1D< double > &aint, Matrix1D< double > &bint, Matrix2D< double > &V, int space_group)
 
void expandToFillSpace (const BasicARTParameters &prm, const CrystalARTRecons &eprm, GridVolume &vol)
 

Detailed Description

Function Documentation

◆ computeIntegerLattice()

void computeIntegerLattice ( const Matrix1D< double > &  a,
const Matrix1D< double > &  b,
double  a_mag,
double  b_mag,
double  ang_a2b_deg,
Matrix1D< double > &  aint,
Matrix1D< double > &  bint,
Matrix2D< double > &  V,
int  space_group 
)

Compute integer lattice vectors and passing matrix. Given two real lattice vectors, this function returns the corresponding integer vectors and the matrix V which passes from a to aint. All vectors are supposed to be 2x1, so V is 2x2. Before computing

aint = Vinv*a; a=V*aint;
bint = Vinv*b; b=V*bint;

Definition at line 394 of file art_crystal.cpp.

402 {
403 
404  // Integer lattice
405  // If we force it to be orthogonal the symmetrization is easier
406  //a_mag=original a_mag/sampling/grid_relatice_size
407  aint.resize(2);
408  bint.resize(2);
409  XX(aint) = ROUND(a_mag_grid);
410  YY(aint) = 0.;
411  XX(bint) = 0.0;
412  YY(bint) = ROUND(b_mag_grid);
413 
414  //different crystalline grids impose different restrictions
415  //on the grid, we will check them here but only if the user
416  //has provided a symmetry file
417 
418  if (space_group != sym_undefined)
419  {
420 
421  switch (space_group)
422  {
423 
424  case sym_P1:
425  break;// no check needed
426  case sym_P2_122://XX(aint) and YY(aint) should be even
427  if (XX(aint) != 2*(int)(XX(aint) / 2) ||
428  YY(bint) != 2*(int)(YY(bint) / 2))
429  {
430  std::cout << "\nLattice connstrains for P2_122 are not satisficed"
431  << "\nRound[mag_a/(sampling*grid_size)] must be even"
432  << "\nPlease modify the parmeters and try again" << std::endl;
433  exit(0);
434  }
435  break;
436  case sym_P22_12://XX(aint) and YY(aint) should be even
437  if (XX(aint) != 2*(int)(XX(aint) / 2) ||
438  YY(bint) != 2*(int)(YY(bint) / 2))
439  {
440  std::cout << "\nLattice connstrains for P22_12 are not satisficed"
441  << "\nRound[mag_a/(sampling*grid_size)] must be even"
442  << "\nPlease modify the parmeters and try again" << std::endl;
443  exit(0);
444  }
445  break;
446  case sym_P42_12://XX(aint) and YY(aint) should be even
447  if (XX(aint) != 2*(int)(XX(aint) / 2) ||
448  YY(bint) != 2*(int)(YY(bint) / 2))
449  {
450  std::cout << "\nLattice connstrains for P4212 are not satisficed"
451  << "\nRound[mag_a/(sampling*grid_size)] must be even"
452  << "\nPlease modify the parmeters and try again" << std::endl;
453  exit(0);
454  }
455  break;
456  case sym_P4:
457  case sym_P6:
458  break;// no check needed
459  default:
460  std::cerr << "\n Congratulations: you have found a bug in the\n"
461  << "routine compute_integer_lattice or\n"
462  << "you are using a non implemented symmetry group\n"
463  << std::endl;
464  exit(0);
465  break;
466  }//switch(space_group) end
467 
468  }//if (prm.fn_sym!="")
469 
470 
471  // Converting matrix
472  // a=D*aint
473  // b=D*bint
474  Matrix2D<double> L(2, 2), LI(2, 2);
475 
476  L .setCol(0, a);
477  L .setCol(1, b);
478  LI.setCol(0, aint);
479  LI.setCol(1, bint);
480  D = L * LI.inv();
481 }
#define sym_P22_12
Definition: symmetries.h:60
#define sym_P4
Definition: symmetries.h:63
#define sym_P6
Definition: symmetries.h:68
#define sym_P2_122
Definition: symmetries.h:59
#define XX(v)
Definition: matrix1d.h:85
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
#define ROUND(x)
Definition: xmipp_macros.h:210
#define sym_P42_12
Definition: symmetries.h:65
#define YY(v)
Definition: matrix1d.h:93
#define sym_P1
Definition: symmetries.h:54
#define sym_undefined
Definition: symmetries.h:53

◆ expandToFillSpace()

void expandToFillSpace ( const BasicARTParameters prm,
const CrystalARTRecons eprm,
GridVolume vol 
)

Expand basis values to fill space. Copy basis values as a crystal in order to fill the whole space determined by the output volume.

Definition at line 486 of file art_crystal.cpp.

488 {
489  std::cout << "Replicating unit cell ...\n";
490 #ifdef DEBUG
491 
492  Image<double> save;
493  vol(0)().getSlice(0, save());
494  save.write("inter_before_filling.xmp");
495 #endif
496 
497  // Resize volume ........................................................
498  Matrix1D<double> corner1(2), corner2(2);
499  VECTOR_R2(corner1,
502  VECTOR_R2(corner2,
505 
507  VECTOR_R2(zero, 0, 0);
508  int a0, aF, b0, bF;
509  // How many lattice units fit inside the output volume
510  find_crystal_limits(corner1, corner2, zero, zero,
511  eprm.a, eprm.b, a0, aF, b0, bF);
512 #ifdef DEBUG
513  std::cerr << "DEBUG_JM: eprm.a: " << eprm.a << std::endl;
514  std::cerr << "DEBUG_JM: eprm.b: " << eprm.b << std::endl;
515  std::cout << "Output Volume size (ZxYxX)=" << prm.Zoutput_volume_size
516  << " " << prm.Youtput_volume_size << " "
517  << prm.Xoutput_volume_size << std::endl;
518  std::cout << "corners:\n" << corner1.transpose() << std::endl
519  << corner2.transpose() << std::endl;
520  std::cout << "a0=" << a0 << "..." << aF << std::endl
521  << "b0=" << b0 << "..." << bF << std::endl;
522 #endif
523 
524  // Expand the volume to the required space
525  corner1 = (double)(a0 - 1) * eprm.a + (double)(b0 - 1) * eprm.b; // CO: I'm not very satisfied with
526  corner2 = (double)(aF + 1) * eprm.a + (double)(bF + 1) * eprm.b; // the +1 and -1 but it works
527  corner1.resize(3);
528  ZZ(corner1) = FIRST_XMIPP_INDEX(prm.Zoutput_volume_size);
529  corner2.resize(3);
530  ZZ(corner2) = LAST_XMIPP_INDEX(prm.Zoutput_volume_size);
531  vol.resize(corner1, corner2);
532 
533  // Copy values ..........................................................
534  Matrix1D<double> r(3);
535  for (size_t n = 0; n < vol.VolumesNo(); n++)
536  {
537  Image<double> &V = vol(n);
539  {
540  if (A2D_ELEM(eprm.unit_cell_mask, i, j))
541  {
542 #ifdef DEBUG2
543  std::cout << "(y,x)=(" << i << "," << j << ") is inside\n";
544 #endif
545 
546  for (int ii = b0; ii <= bF; ii++)
547  for (int jj = a0; jj <= aF; jj++)
548  {
549  if (jj == 0 && ii == 0)
550  continue;
551  XX(r) = j + ii * XX(eprm.bint) + jj * XX(eprm.aint);
552  YY(r) = i + ii * YY(eprm.bint) + jj * YY(eprm.aint);
553  ZZ(r) = STARTINGZ(VOLMATRIX(V));
554  if (!VOLMATRIX(V).outside(r))
555  {
556 #ifdef DEBUG2
557  std::cout << " Is copied to (" << (int)YY(r) << ","
558  << (int)XX(r) << ")\n";
559 #endif
560  // copy values if inside volume
561  for (int k = STARTINGZ(VOLMATRIX(V));
562  k <= FINISHINGZ(VOLMATRIX(V)); k++)
563  VOLVOXEL(V, k, (int)YY(r), (int)XX(r)) =
564  VOLVOXEL(V, k, i, j);
565  }
566  }
567  }
568  }
569  }
570 #ifdef DEBUG
571  vol(0)().getSlice(0, save());
572  save.write("inter_after_filling.xmp");
573 #endif
574 }
#define VECTOR_R2(v, x, y)
Definition: matrix1d.h:112
#define A2D_ELEM(v, i, j)
#define VOLVOXEL(V, k, i, j)
void resize(const Matrix1D< double > &corner1, const Matrix1D< double > &corner2)
Definition: grids.h:873
#define VOLMATRIX(V)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
Matrix1D< double > bint
Second lattice vector approximated to integer numbers (BCC units)
Definition: art_crystal.h:72
Matrix1D< double > a
First lattice vector (BCC units)
Definition: art_crystal.h:66
#define FINISHINGZ(v)
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
void find_crystal_limits(const Matrix1D< double > &proj_corner1, const Matrix1D< double > &proj_corner2, const Matrix1D< double > &cell_corner1, const Matrix1D< double > &cell_corner2, const Matrix1D< double > &a, const Matrix1D< double > &b, int &iamin, int &iamax, int &ibmin, int &ibmax)
size_t VolumesNo() const
Definition: grids.h:1003
Matrix1D< double > b
Second lattice vector (BCC units)
Definition: art_crystal.h:68
MultidimArray< int > unit_cell_mask
Definition: art_crystal.h:85
#define XX(v)
Definition: matrix1d.h:85
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
#define j
#define YY(v)
Definition: matrix1d.h:93
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
#define STARTINGZ(v)
int * n
Matrix1D< double > aint
First lattice vector approximated to integer numbers (BCC units)
Definition: art_crystal.h:70
#define ZZ(v)
Definition: matrix1d.h:101
void getSlice(Image< double > &op)
ql0001_ & zero(ctemp+1),(cvec+1),(a+1),(b+1),(bl+1),(bu+1),(x+1),(w+1), &iout, ifail, &zero,(w+3), &lwar2,(iw+1), &leniw, &glob_grd.epsmac