Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. $HistoryLength = 0;
  2. SetSystemOptions[
  3. "SparseArrayOptions" -> {"TreatRepeatedEntries" -> 1}];
  4. f[{a_, b_, c_}] :=
  5. If[a <= 0,
  6. "NA", {Round[200 b/a], Round[200 c/a], 1000/(a^2 + b^2 + c^2)}];
  7.  
  8. initialCell =
  9. Table[{0.1, Sin[[Theta]]/5.0,
  10. Cos[[Theta]]/5.0}, {[Theta], [Pi]/16, 2 [Pi], [Pi]/16}];
  11.  
  12. translatedCell[m1_, m2_,
  13. m3_] := {m1 + (-1)^m1 #[[1]], m2 + (-1)^m2 #[[2]],
  14. m3 + (-1)^m3 #[[3]]} & /@ initialCell;
  15. A = Flatten[
  16. Table[translatedCell[m1, m2, m3], {m1, 0, 18}, {m2, -18,
  17. 18}, {m3, -18, 18}], 3];
  18. << Developer`
  19.  
  20. B = Cases[f /@ A, Except["NA"]];
  21.  
  22. F = Cases[B, _?(Abs[#[[1]]] <= 800 && Abs[#[[2]]] <= 800 &)];
  23.  
  24. G = SparseArray[{-801 + #[[1]], -801 + #[[2]]} -> 1.5/32 #[[3]] & /@
  25. F];
  26. {n1, n2} = Dimensions[G];
  27.  
  28. fLor = Compile[{{x, _Integer}, {y, _Integer}}, (0.12/(
  29. 0.12 + x^2 + y^2))^1.15, RuntimeAttributes -> {Listable},
  30. CompilationTarget -> "C"];
  31. lor = RotateRight[
  32. fLor[#[[All, All, 1]], #[[All, All, 2]]] &@
  33. Outer[List, Range[-Floor[n1/2], Ceiling[n1/2] - 1],
  34. Range[-Floor[n2/2], Ceiling[n2/2] - 1]], {Floor[n1/2],
  35. Floor[n2/2]}];
  36.  
  37. Image[Sqrt[1.0 n1 n2]
  38. Abs[InverseFourier[
  39. Fourier[G] Fourier[lor]]][TensorProduct]ToPackedArray[{1.0, 0.3,
  40. 0.1}], Magnification -> 1]
  41.  
  42. initialCell =
  43. Table[{0.1, Sin[[Theta]]/5.0,
  44. Cos[[Theta]]/5.0}, {[Theta], [Pi]/16, 2 [Pi], [Pi]/16}];
  45. translatedCell[m1_, m2_,
  46. m3_] := {m1 + (-1)^m1 #[[1]], m2 + (-1)^m2 #[[2]],
  47. m3 + (-1)^m3 #[[3]]} & /@ initialCell;
  48. B = Cases[
  49. f /@ (Flatten[
  50. Table[translatedCell[m1, m2, m3], {m1, -20, 20}, {m2, -20,
  51. 20}, {m3, -20, 20}],
  52. 3].{{0.5`, -0.7071067811865475`, 0.5`}, {0.5`,
  53. 0.7071067811865475`, 0.5`}, {-0.7071067811865475`, 0.`,
  54. 0.7071067811865475`}}), Except["NA"]];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement