COS 126 Atomic Theory of Matter Atomic Theory

  • Slides: 14
Download presentation
COS 126 – Atomic Theory of Matter

COS 126 – Atomic Theory of Matter

Atomic Theory Overview n Brownian Motion n n Random collision of molecules Displacement over

Atomic Theory Overview n Brownian Motion n n Random collision of molecules Displacement over time fits a Gaussian distribution

Atomic Theory Overview n Avogadro’s Number n Number of atoms needed to equal substances

Atomic Theory Overview n Avogadro’s Number n Number of atoms needed to equal substances atomic mass in grams n n NA atoms of Carbon-12 = 12 grams Can calculate from Brownian Motion n Variance of Gaussian distribution is a function of resistance in water, number of molecules

Bead. java n n Represent particles (beads) in water API n n n n

Bead. java n n Represent particles (beads) in water API n n n n public public Bead() void add(int i, int j) int mass() // number of pixels double distance. To(Bead b) // from center (average) String to. String() Only need 3 values to efficiently store Thoroughly test (simple main)

Bead. Finder. java n n Locate all beads in a given image API n

Bead. Finder. java n n Locate all beads in a given image API n public Bead. Finder(Picture picture, double threshold) n Calculate luminance (see Luminance. java, 3. 1) n n Find beads with DFS (see Percolation. java, 2. 4) n n Count pixels with at luminance > threshold The hard part, next slide… public Bead[] get. Beads(int min. Size) n n Returns all beads with at least min. Size pixels Array must be of size equal to number of beads

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited Traverse image n n n Dark pixel – mark as visited, continue Light pixel – create new bead, call dfs DFS algorithm n n n If pixel out-of-bounds, return If pixel has been visited, return If pixel is dark, mark + return Add pixel to current bead, mark as visited Recursively visit up, down, left, right

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited Traverse image n n n Dark pixel – mark as visited, continue Light pixel – create new bead, call dfs DFS algorithm n n n If pixel out-of-bounds, return If pixel has been visited, return If pixel is dark, mark + return Add pixel to current bead, mark as visited Recursively visit up, down, left, right

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited Traverse image n n n Dark pixel – mark as visited, continue Light pixel – create new bead, call dfs DFS algorithm n n n If pixel out-of-bounds, return If pixel has been visited, return If pixel is dark, mark + return Add pixel to current bead, mark as visited Recursively visit up, down, left, right

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited Traverse image n n n Dark pixel – mark as visited, continue Light pixel – create new bead, call dfs DFS algorithm n n n If pixel out-of-bounds, return If pixel has been visited, return If pixel is dark, mark + return Add pixel to current bead, mark as visited Recursively visit up, down, left, right

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited Traverse image n n n Dark pixel – mark as visited, continue Light pixel – create new bead, call dfs DFS algorithm n n n If pixel out-of-bounds, return If pixel has been visited, return If pixel is dark, mark + return Add pixel to current bead, mark as visited Recursively visit up, down, left, right

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited

Bead Finder - Depth First Search n n Use boolean[][] array to mark visited Traverse image n n n Dark pixel – mark as visited, continue Light pixel – create new bead, call dfs DFS algorithm n n n If pixel out-of-bounds, return If pixel has been visited, return If pixel is dark, mark + return Add pixel to current bead, mark as visited Recursively visit up, down, left, right

Bead. Tracker. java n n Track beads between successive images Single main function n

Bead. Tracker. java n n Track beads between successive images Single main function n n Take in a series of images Output distance traversed by all beads for each time-step n For each bead found at time t+1, find closest bead at time t and calculate distance n n Not the other way around! Don’t include if distance > 25 pixels (new bead)

Avogadro. java n Analyze Brownian motion of all calculated displacements n n Lots of

Avogadro. java n Analyze Brownian motion of all calculated displacements n n Lots of crazy formulas, all given, pretty straightforward Be careful about units in the math, convert pixels to meters, etc.

Random Thoughts… n n Bead. Tracker and Avogadro are separate clients, must recompile both

Random Thoughts… n n Bead. Tracker and Avogadro are separate clients, must recompile both Can still do Avogadro without other parts working, use sample input Only keep at most two pictures open at a time (run out of memory otherwise) Output format - System. out. printf() n n "%6. 3 f" -> _2. 354 "%10. 4 e" -> 1. 2535 e-23