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

AstonJ
A recent chat with @leifericf inspired this thread - he’s worked in the gaming industry, and so it got me wondering what kind of industri...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
stefannovak
Hi all, I’m going to be giving a little 20 minute tech talk at my company which uses .NET C# across all of our 100ish size IT team. I’m ...
New
NKTgLaw
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-inspi...
New
bartblast
Hologram provides a way to write your entire web application in Elixir, with automatic transpilation to JavaScript for the frontend. It h...
New
thiagomajesk
I came across this PKGX tool the other day, if anyone here is using it, could you share your experience? I’m wondering how useful it wou...
New
James_E
I see that the current ExUnit source code has support for rich failure messages on a small whitelist of “recognized” assertion patterns, ...
New
tcoopman
Yesterday I watched OpenTelemetry: From Desire to Dashboard and it triggered me to take a new look at telemetry in Elixir. But I don’t k...
New
gushonorato
Hey everyone, I’ve been working with Elixir for over 5 years and I’m a big enthusiast of the language. However, when starting new projec...
New
darkmarmot
At HCA Healthcare (500k employees and contractors), we’re currently experimenting with Elixir for both data integration (to handle parsin...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
Tee
can someone please explain to me how Enum.reduce works with maps
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
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement