Hidden WordScanner
Private scans · No account required

DuckieDai Bragg's Law

Solve n*lambda = 2*d*sin(theta), including a guided conversion from an XRD 2-theta reading.

Version 1.0.0 · Not calculator tested

← Back to Calculator Program Library

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.

chemistry · MIT License

Overview

Solve n*lambda = 2*d*sin(theta), including a guided conversion from an XRD 2-theta reading.

Usage

Inputs

  • Positive integer reflection order
  • Wavelength and lattice-plane spacing in the same length unit
  • Bragg theta in degrees, or measured 2-theta in degrees

Outputs

  • Requested spacing, angle, wavelength, or calculated reflection order

Units: Lambda and d must use the same length unit; theta and 2-theta are entered in degrees.

Assumptions and limitations

Assumptions

  • The stated planes, wavelength, and diffraction order describe the same elastic diffraction peak.

Constraints

  • Order is positive; theta is greater than 0 and at most 90 degrees; 2-theta is greater than 0 and at most 180 degrees; inverse-sine input cannot exceed 1.

Known failures

  • A calculated value near an integer does not by itself assign a diffraction peak.
  • Instrument geometry, uncertainty, and sample effects are not modeled.

Compatibility and review

Review status
Not calculator tested
Tested on
The owner reports personally testing the supplied archive programs on a calculator; exact model, OS, and Python App versions were not recorded
What happened
Owner reported interactive testing is disclosed, but the published bytes are not labeled independently calculator tested because the environment is unrecorded and Arrhenius received a narrow intake correction
Dependencies
math
Suggested calculator name
BRAGG — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Browser preview

Try the DuckieDai calculator screen

Follow the same opening, solve menu, prompts, validation, and result flow as the downloadable program.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. from math import sin,asin,radians,degrees
  2. def duckiedai_intro(program_name,wait=True):
  3. title=program_name[:16]
  4. empty=16-len(title)
  5. left=empty//2
  6. right=empty-left
  7. print("+----------------------+")
  8. print("| "+" "*left+title+" "*right+" |")
  9. print("| |")
  10. print("| __ |")
  11. print("| ___(o )> quack! |")
  12. print("| \\ <_. ) |")
  13. print("| `---' |")
  14. print("| by DuckieDai |")
  15. print("+----------------------+")
  16. print("Loading...")
  17. if wait:
  18. input("Press enter to start ")
  19. print("\n"*6)
  20. def pos(s):
  21. while 1:
  22. try:
  23. x=float(input(s))
  24. if x>0:return x
  25. except:pass
  26. print("Enter a positive #")
  27. def whole(s):
  28. while 1:
  29. try:
  30. x=int(input(s))
  31. if x>0:return x
  32. except:pass
  33. print("Enter a whole #")
  34. def angle(s,top=90):
  35. while 1:
  36. x=pos(s)
  37. if x<=top:return x
  38. print("Angle is too large")
  39. def menu():
  40. while 1:
  41. try:
  42. x=int(input("Choose 1-5: "))
  43. if x>0 and x<6:return x
  44. except:pass
  45. print("Choose 1 to 5")
  46. duckiedai_intro("BRAGGS LAW")
  47. print("BRAGG'S LAW")
  48. print("n*lambda=2*d*sin(t)")
  49. print("1 Find d")
  50. print("2 Find theta")
  51. print("3 Find lambda")
  52. print("4 Find order n")
  53. print("5 d from 2theta")
  54. c=menu()
  55. if c==1:
  56. n=whole("Order n: ")
  57. w=pos("Lambda: ")
  58. t=angle("Theta deg: ")
  59. d=n*w/(2*sin(radians(t)))
  60. print("d =",d)
  61. print("2theta =",2*t)
  62. elif c==2:
  63. n=whole("Order n: ")
  64. w=pos("Lambda: ")
  65. d=pos("d: ")
  66. r=n*w/(2*d)
  67. if r>1:print("No Bragg angle")
  68. else:
  69. t=degrees(asin(r))
  70. print("theta =",t)
  71. print("2theta =",2*t)
  72. elif c==3:
  73. n=whole("Order n: ")
  74. d=pos("d: ")
  75. t=angle("Theta deg: ")
  76. print("lambda =",2*d*sin(radians(t))/n)
  77. elif c==4:
  78. w=pos("Lambda: ")
  79. d=pos("d: ")
  80. t=angle("Theta deg: ")
  81. n=2*d*sin(radians(t))/w
  82. near=round(n)
  83. print("Calculated n =",n)
  84. print("Nearest order =",near)
  85. if near<1:print("No positive order")
  86. elif abs(n-near)<.001:print("Matches integer order")
  87. else:print("Not an integer order")
  88. else:
  89. n=whole("Order n: ")
  90. w=pos("Lambda: ")
  91. t=angle("2theta deg: ",180)/2
  92. print("theta =",t)
  93. print("d =",n*w/(2*sin(radians(t))))
  94. input("ENTER for guide: ")
  95. print("QUICK GUIDE")
  96. print("n=1,2,3,...")
  97. print("d and lambda: same")
  98. print("Bragg uses theta")
  99. print("XRD often gives 2theta")
  100. print("DuckieDai: done!")
  101. input("ENTER to exit: ")
Filename
bragg.py
Size
2301 bytes
SHA-256
58e4d702646472cfe19bd4f3fb0a8ee814527e1843791f8bf24756ec532ff5b3

Transfer and launch

  1. Confirm that your calculator is the Python-capable model named above. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.
  2. Download the .py source above and verify its SHA-256 digest if your computer provides that option.
  3. Use TI Connect CE to send the Python file to a compatible calculator. BRAGG is a suggested name; you may choose another valid, unique calculator name.
  4. Open the Python App, select the program, and check sample inputs before relying on other results.

Read the complete installation, launch, troubleshooting, and removal guide.

Availability does not mean a teacher, school, or exam permits this program. Follow the applicable rules.

Version history

Any source change requires a new immutable version and digest. Historical downloads remain available only while their review records remain valid.