home.social

#qotojournal — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #qotojournal, aggregated by home.social.

  1. 2021-03-26, 19:05, Friday

    I promised a few paragraphs about x-ray diffraction, so here it goes. This is mostly unedited because I’m tired and lazy.

    Basically, light has a property to undergo what’s called diffraction: shine a laser beam on a grated piece of plastic and beam will split into an uneven number of new beams. Using this pattern and some trigonometry you can calculate the wavelength of light if you know how fine the grating is and the angle between beams. This works only when wavelength is a few times smaller than the grating size.

    Now, the important bit is that atoms in crystal sort of work like grating. Light reflects from different layers of atoms differently and this forms the same diffraction pattern. Since the distance between atomic layers determines the structure of the crystal, we can now measure it using light and some math called Bragg’s law. The only thing we need is a light source with fixed, well-known and very small wavelength. Now, the “grating” in our case is approximately 2-4*10^-10 m, or 2-5 angstrem.

    Conveniently, metallic anode, when put in a vacuum and under high voltage, emits high energy photones, generally of a fixed wavelength, corresponding to the valent electron’s excited state. And if we use copper, this wavelength is roughly 1.51 angstrem, which is about what we need.

    Now that all elements are in place, we just need to build a complex machinery that will hold our sample, put a piece of copper under a few kilovolts, cool it down simultaneously, while also rotating a detector to capture light intensities under a range of angles. Different lattices will give different diffraction patterns, and one can be calculated from another.

    And this is more or less how x-ray diffraction works.

    #qotojournal #science #xrd #materialsciences

  2. For any ruby :ruby: devs out there, wanted to share a neat little open-source :opensource: module I wrote to solve a common problem. Keep in mind ruby is not my main language so if there is a batter approach here I'm all ears.

    Basically right now I have a game (text based mud) and in normal and expected fashion objects in the game are created when their objects get initialized, such as a new player being created. The system then periodically saves the universe by marshalling all the object into some serialized format and saves it to a file from time to time. As tends to be the case with serialization, however, when an object is restored, such as a previous player logging out and back in, then the class is created directly without the initialize method getting called , its class and instance variables are simply populated directly.

    This is where problems can arise if you change the system and add new features (such as a new variable to an object). New objects that are created will populate the new variable correctly through the initialize method however already existing players will not have that variable set at all (it won't be nil, it simply wont be set, which is a distinctly different state). This is the problem I solved.

    What I did was created a mix-in module that lets you set default values for variables, once a class is reinstated from storage it checked if any variables that have defaults are unset (nil variables are considered set) and then applies the default value to them. In this way legacy objects will be able to update to new code changes automatically when it loads. To prevent duplicating code you can even intentionally leave it out of the initialize method and rely on the defaults when it is appropriate to do so.

    Moreover the defaults do not have to be static values but can be determined based on the existing state of the object, which makes them dynamic and flexible... a class that uses the mixin could look like this:

    require 'defaults'

    class Foo
    include Defaults

    # @bar defaults to @baz*2
    default(:bar) { |this| this.baz * 2 }
    # @faaboo defaults to 178
    default(:faaboo) { 178 }

    def initialize
    @baz = 13

    #this line can be ommited
    @bar = 26
    # if you add this line instead
    load_defaults
    #either work fine
    end
    end

    Here is a link to the module:

    git.qoto.org/aethyr/Aethyr/-/b

    You can see a class that utilizes this new feature here:

    git.qoto.org/aethyr/Aethyr/-/b

    #Ruby #RubyLang #Programming #Coding #software #ComputerScience @Science #code #source #sourcecode #opensource #oss #game #gaming #gamedev #QotoJournal

  3. Good morning.

    2021-01-21, 08:22, Thursday. Drinking my morning coffee (cezve with some cinnamon) and preparing for my report. I'll probably make a separate post about it since it's an opportunity to tell about my scientific research. For now I'm in a mood to write some more "tips".

    STEM tips №2: build your foundation. There is a very good reason for all textbooks on the same subject to convey material in the same order. It is not tradition, it is crucial for understanding concepts. The only exception in basic sciences I am familiar with is organic chemistry: Clayden's textbook is wildly diffirent from standart approach, but I'm not sure how it feels to actually use it for studying without prior knowledge of organic chemistry.

    I digress. The particular order most textbooks follow builds new concepts on top of previous ones, and this principle applies throughout your academic career. Let's say you skipped a trigonometry introduction in high school. You crammed for the test and did fine, memorizing all your pi-over-2/3/4/6, but there is no solid understanding of the concept. Now you will struggle in your further math classes. Not only that, in mechanics knowledge of trigonometry is implied, the same applies for calculus, most of the physics and a bunch of other disciplines.

    So the takeaway is: don't skip basic topics and make sure you know them very well. Otherwise your ignorance will backfire, usually sooner than later.

    #stem #stemtips #student #uni #science #life #lifesyle #qotojournal

  4. Good morning.

    2021-01-22, 08:20, Friday. Plain black coffee with very high ratio, almost 10:1. I like it, though.

    Yesterday I finished my fifth semester with science work report. Might as well write about my work here. So there are a lot of thermodynamic models of liquids. Modern ones are quite precise, but complicated and have a lot of maths involved. They are very useful to predict the reaction equilibrium or solution's properties, but because of their complexity you need to run them through computer. So people tend to create their own implementations of these models and use them, but diffirent implementations perform calculations slightly diffirently and this can affect results of the study.
    The idea is to create a more or less versatile program with GUI, that would be easy to use by anyone and make results reproducible. I now managed to make a prototype with saving, loading and calculating quilibria. The core code of implementation is not mine, however, I use pre-coded model (my colleague made it) to create GUI and more or less intuitive logic around it. The entire thing is in C/C++ and runs quite smootly on binary systems.

    #stem #stemtips #student #uni #science #life #lifesyle #qotojournal #coffee #thermodynamics #programming

  5. Do you guys know the story about Eurisko, one of the earliest Evolutionary Algorithms attempted, done back in the 80's by Lenat. An interesting bug had arisen that is both insightful and amusing.

    The purpose of the problem is that it evolved new heuristics for some problem it is given and then try them to solve the problem. Heuristics that work would get a higher score and ones that dont get a lower score. Eventually it would learn which a re best and would try the heuristics in order on new problems to find solutions.

    One day after a night of solving problems Lenat came in and noticed there was heuristic that scored 999 out of 1000, the highest score ever seen. Excited he tried to figure out what the heuristic was doing.

    As it turns out the heuristic basically said "whenever a problem is solved add this heuristic to the list of heuristics used to generate the solution"

    You can read about this bug, and the project in general in this book. See page 90 for specific reference to the bug:

    users.cs.northwestern.edu/~mek

    #Science #MachineLearning #AI #AGI #EvolutionaryComputing #Evolution #Programming #CS #ComputerScience #QotoJournal