<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://kongaskristjan.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kongaskristjan.github.io/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-08-03T09:35:05+00:00</updated><id>https://kongaskristjan.github.io/feed.xml</id><title type="html">Kristjan Kongas</title><subtitle>Projects and writing by Kristjan Kongas — NaNsense, an interactive PyTorch debugger; fire-hpp, a header-only C++ CLI library; and experiments in reinforcement learning and physics simulation.</subtitle><author><name>Kristjan Kongas</name></author><entry><title type="html">Phase Transition demo</title><link href="https://kongaskristjan.github.io/2020/02/09/phase-transition.html" rel="alternate" type="text/html" title="Phase Transition demo" /><published>2020-02-09T00:00:00+00:00</published><updated>2020-02-09T00:00:00+00:00</updated><id>https://kongaskristjan.github.io/2020/02/09/phase-transition</id><content type="html" xml:base="https://kongaskristjan.github.io/2020/02/09/phase-transition.html"><![CDATA[<p>Nothing in this simulation knows what a liquid is. Particles simply attract and
repel each other, and the familiar states of matter — solid, liquid and gas —
emerge from that. Heat the particles up and they fly apart; cool them down and
they clump together.</p>

<p>The simulator is written in C++ and compiled to WebAssembly, so the physics
below runs in your browser. Grab it with the mouse:</p>

<div class="demo">
  <canvas id="canvas" oncontextmenu="event.preventDefault()" aria-label="Interactive particle simulation"></canvas>
  <p class="demo__hint">
    <span><kbd>c</kbd> create &nbsp;<kbd>s</kbd> spray &nbsp;<kbd>p</kbd> push &nbsp;<kbd>h</kbd> heat</span>
    <span>Left button applies the mode, right button reverses it</span>
    <span>Mouse wheel resizes the range of influence</span>
  </p>
</div>

<script type="text/javascript">
    var Module = {
        canvas: (function() { return document.getElementById('canvas'); })()
    };
</script>

<script src="/assets/PhaseTransition.js"></script>

<p>Use your mouse to create and influence the particles. There are four modes of
interaction: creating, spraying, pushing and heating, each of which can be
activated with keys <code class="language-plaintext highlighter-rouge">c</code>, <code class="language-plaintext highlighter-rouge">s</code>, <code class="language-plaintext highlighter-rouge">p</code> and <code class="language-plaintext highlighter-rouge">h</code> respectively. Once in a mode, this
action can be carried out on particles by holding the left mouse button. The
right mouse button does the opposite of the activated mode’s function — so in
heating mode it cools the particles down, which is how you condense a gas into
a liquid.</p>

<p>The number of particles, average velocity, and average temperature (inside the
range of influence) are displayed in the upper left corner of the display.</p>

<p>Currently, the demo only uses a single core due to compatibility reasons with
most browsers. Performance suffers — the native build is considerably faster.</p>

<p>Source code is on <a href="https://github.com/kongaskristjan/PhaseTransition">GitHub</a>,
and there’s a <a href="https://youtu.be/SFf3pcE08NM">video of the simulation</a> running
natively, with rather more particles than a browser will tolerate.</p>]]></content><author><name>Kristjan Kongas</name></author><category term="C++" /><category term="WebAssembly" /><category term="Simulation" /><summary type="html"><![CDATA[A 2D particle simulator written in C++ and compiled to WebAssembly, where solid, liquid and gas-like states of matter emerge from the physics.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://kongaskristjan.github.io/assets/media/og-card.png" /><media:content medium="image" url="https://kongaskristjan.github.io/assets/media/og-card.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>