NKTgLaw

NKTgLaw

NKTg Law: A Physics-Inspired Approach to Variable-Mass Motion in Elixir Systems

Hello fellow BEAM enthusiasts,

I’d like to introduce a conceptual idea I’ve been developing, which I call NKTg Law. It’s a physics-inspired framework aimed at modeling how an entity’s motion tendency shifts when its mass varies over time—something that could map well into Elixir/Erlang architectures, especially for distributed systems needing dynamic behaviour (e.g., actor systems with changing load, battery mechanics in games, scalable simulations).


NKTg Law – Conceptual Overview

I define two core values:

  • NKTg₁ = x × p, where:
    • x = position or displacement metric,
    • p = m × v = linear momentum (mass * velocity).
    • Interpretation:
      • NKTg₁ > 0 → object tends to move away from equilibrium (amplifying motion).
      • NKTg₁ < 0 → object tends to move toward equilibrium (stabilizing).
  • NKTg₂ = (dm/dt) × p, where:
    • dm/dt = rate of change of mass.
    • Interpretation:
      • NKTg₂ > 0 → mass change supports motion (like growth or power-up).
      • NKTg₂ < 0 → mass change resists motion (like draining resources).

Why It Might Be Useful for Elixir/BEAM Patterns

  • The BEAM excels at modeling concurrent, stateful processes—each could track its own x, v, m, dynamically adjusted in real-time.
  • This could empower novel features:
    • Adaptive rate limiting: processes slow down as their “mass” (load) increases.
    • Self-throttling workflows: nodes in a cluster reduce throughput under heavy resource exhaustion.
    • Game mechanics: actors that gain momentum as they “power up” (mass ↑) or slow when “hurt” (mass ↓).

Questions for the Community

  1. Has anyone used Elixir/OTP to model systems with dynamic “mass” or weight affecting behavior? What patterns did you use (GenServer, GenStage, Flow, etc.)?
  2. Would it make sense to encapsulate dm/dt and momentum logic into a reusable module or behaviour, rather than peppering logic across individual processes?
  3. Do you have ideas for visualizing or monitoring these dynamics—perhaps via :telemetry, custom dashboards, or observability tools?
  4. Would you be interested in sample code implementing a simple Elixir GenServer that updates NKTg₁ and NKTg₂ each handle_info(:tick, state)?

I’d love to hear your feedback or pointers to similar mechanics—especially any distributed systems concepts using BEAM that factor in changing resource usage or adaptive behavior.

Looking forward to your thoughts!

NKTgLaw

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hey welcome!

You’re not the first person to identify the Beam as a potentially good platform for a simulation. The issue however when doing things like physics simulations is at least 3 fold:

  1. it’s critical that every entity gets the same number of ticks. If not, then some entities are essentially moving faster in time than others
  2. it’s critical to deterministically handle interactions between entities. This often reduces the practical concurrency as entities are having to wait to talk to each other.
  3. most critically, physics simulations are wildly CPU bound, and thus benefit most from languages that can produce ideal low level code.

In all 3 aspects you’re running against the grain of the BEAM. It is generally fair to all of its concurrent processes but not at the “over 1 million ticks every GenServer will get exactly the same number of ticks” fair. And from a CPU performance standpoint you’re going to get obliterated by languages which model this problem as essentially zipping through arrays of values.

Concurrency in the BEAM is tuned toward IO related use cases. It does quite well on the CPU tasks that happen along side those, but for problems where the entire problem is a number crunching exercise it just doesn’t play to the BEAMs strengths.

The only caveat is that if you can model this problem in say Nx and then it’s actually compiling to GPU code then that’s a whole other thing. I have next to no experience with that though.

EDIT: rereading your post it’s possible I misunderstood your goal here. Is it less about modeling physics and more about using physics ideas to in some way regulate ordinary elixir processes?

Where Next?

Popular in Discussions Top

artimath
I think I’ve tried 5 different graph database libraries in the last two days and not a single one has been able to connect to a remote/lo...
New
BigTom
With Phoenix, Liveview, Ash, Oban Web, Nx, Livebook, Beacon, Liveview Native, Flame, Nerves etc all getting mature, are there any major g...
New
AstonJ
Bart’s talk about Hologram got me wondering what kind of apps or components people are thinking about building (or think could be built) ...
New
ashkan117
I’m wondering how do people structure their JSON Api’s with Phoenix. Using the blogs example, let’s say I have a blogs view like the foll...
New
garrison
I have been thinking about how I might write a new web framework in Elixir. (Not committing to anything, just thinking about it.) One th...
New
yordisprieto
I am trying to figure out a good architecture and implementation for authZ. Recently, I discover GitHub - open-policy-agent/opa: Open Po...
New
travisf
In upgrading from Ecto 2 to Ecto 3 I’m dealing with a failing test. If I use ExMachina build(:address) I’ll get an error trying to put_e...
New
michallepicki
Hello! To save some time when switching projects or development machines, I glued together an asdf plugin that uses Erlang precompiled b...
New
kusokuzeshiki
I tried to generate pages with claude code and fluxon ui. I ask to claude code to generate real world page samples, the results are thes...
New
AstonJ
There seems to be a lot of buzz around DeepSeek at the moment, with some saying it’s a ChatGPT killer. The most remarkable thing (if they...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement