<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rubén Ortiz</title>
    <description>The latest articles on DEV Community by Rubén Ortiz (@rubenortz_).</description>
    <link>https://dev.to/rubenortz_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3680449%2F137e01c3-f6d4-4ba3-9148-ed590c57efc4.jpg</url>
      <title>DEV Community: Rubén Ortiz</title>
      <link>https://dev.to/rubenortz_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rubenortz_"/>
    <language>en</language>
    <item>
      <title>How I Built a Real-Time Physics Engine for Electrical Engineering with Flutter</title>
      <dc:creator>Rubén Ortiz</dc:creator>
      <pubDate>Fri, 26 Dec 2025 22:17:01 +0000</pubDate>
      <link>https://dev.to/rubenortz_/how-i-built-a-real-time-physics-engine-for-electrical-engineering-with-flutter-2jfh</link>
      <guid>https://dev.to/rubenortz_/how-i-built-a-real-time-physics-engine-for-electrical-engineering-with-flutter-2jfh</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk9557rhrbzwy6a209g27.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk9557rhrbzwy6a209g27.png" alt=" " width="800" height="1777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem: Field Work is Stuck in the 90s
&lt;/h3&gt;

&lt;p&gt;As an electrical engineer, I spent years taking notes on paper at construction sites, only to spend my nights at home fighting with endless Excel sheets to verify safety standards and generate quotes.&lt;/p&gt;

&lt;p&gt;I wanted to come home and &lt;strong&gt;rest&lt;/strong&gt;, not continue working. &lt;/p&gt;

&lt;p&gt;Most existing apps were just simple calculators or closed-source "black boxes." I decided to build &lt;strong&gt;Electrics-App&lt;/strong&gt;: an Open Source "Digital Twin" for the pocket that understands real physics and strict regulatory standards (REBT/IEC).&lt;/p&gt;




&lt;h2&gt;
  
  
  🧬 The Core: A Bidirectional Physics Engine
&lt;/h2&gt;

&lt;p&gt;The biggest challenge was handling the complexity of an electrical installation. It’s not a list; it’s a &lt;strong&gt;Directed Acyclic Graph (DAG)&lt;/strong&gt;. To solve this, I implemented a &lt;strong&gt;Two-Pass Calculation Algorithm&lt;/strong&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Bottom-Up Pass (Load Flow)
&lt;/h3&gt;

&lt;p&gt;We traverse from the loads (leaf nodes) up to the source.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vector Summation:&lt;/strong&gt; We don't just add Amps. We perform vector addition of Active ($P$) and Reactive ($Q$) power to find the Apparent Power ($S$) and Design Current ($I_b$).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simultaneity Factors:&lt;/strong&gt; Applying coefficients at each panel level recursively to reflect real-world diversity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Top-Down Pass (Impedance &amp;amp; Faults)
&lt;/h3&gt;

&lt;p&gt;Once we know the load, we traverse from the source down.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Impedance Propagation:&lt;/strong&gt; We calculate the cumulative Resistance ($R$) and Reactance ($X$) of every cable and connection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Voltage Drop ($\Delta U$):&lt;/strong&gt; Calculations based on the &lt;strong&gt;UNE-HD 60364-5-52&lt;/strong&gt; standard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Short-Circuit ($I_{cc}$):&lt;/strong&gt; Calculating max and min fault levels to ensure protections actually trip when they should.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example of the impedance logic in our engine&lt;/span&gt;
&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;calculateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;R&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;R&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🌳 Data Architecture: Recursive Trees
&lt;/h2&gt;

&lt;p&gt;I used a Composite Pattern to allow for infinite nesting. A PanelNode can contain ProtectionNodes, which contain CableNodes, which might lead to another PanelNode.&lt;/p&gt;

&lt;p&gt;To handle this in Flutter, I chose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;BLoC/Cubit&lt;/strong&gt;: For predictable state management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Freezed&lt;/strong&gt;: For type-safe, immutable data models.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Isar&lt;/strong&gt; DB: A high-performance NoSQL database that allows the app to be Offline-First. No cloud needed when you are in a basement!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🤖 Automating the Catalog with AI
&lt;/h2&gt;

&lt;p&gt;One of the "magic" features is the AI Component Agent. Adding technical specs for every circuit breaker on the market is a nightmare.&lt;/p&gt;

&lt;p&gt;I built a Python script that monitors GitHub Issues. When a user requests a component:&lt;/p&gt;

&lt;p&gt;They open an issue: [COMPONENT REQUEST] Schneider iDPN H Vigi.&lt;/p&gt;

&lt;p&gt;** A GitHub Action triggers the script. **&lt;/p&gt;

&lt;p&gt;An AI model parses the manufacturer's data and maps it to a JSON template.&lt;/p&gt;

&lt;p&gt;It creates a PR to update the app's internal library automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚖️ Regulatory Transparency
&lt;/h2&gt;

&lt;p&gt;Engineering software shouldn't be a black box. I’ve hardcoded the REBT (Spanish Regulation) and UNE/IEC standards into the engine.&lt;/p&gt;

&lt;p&gt;I even uploaded the reference PDFs directly to the repository. If the app says a cable is undersized, you can check the code against the actual law in the same repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  📱 Tour of the App
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yd873t681xipv1t7tgq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yd873t681xipv1t7tgq.png" alt=" " width="800" height="1777"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1gqt37xwm0e651iwnr8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz1gqt37xwm0e651iwnr8.png" alt=" " width="800" height="1777"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2gvwhff9qsvzr9e08xy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2gvwhff9qsvzr9e08xy.png" alt=" " width="800" height="1777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Health Check System:
&lt;/h2&gt;

&lt;p&gt;A "traffic light" dashboard that compares field measurements vs. theoretical models.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automatic Budgeting:
&lt;/h2&gt;

&lt;p&gt;Generating professional quotes on-site.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤝 Open Source &amp;amp; Contributions
&lt;/h2&gt;

&lt;p&gt;I’ve opened this project because I believe our industry deserves better, more collaborative tools.&lt;/p&gt;

&lt;p&gt;Whether you are a Flutter Dev interested in complex state management or an Engineer who wants to audit the physics logic, I’d love your help!&lt;/p&gt;

&lt;p&gt;⭐ Check out the Repo: &lt;a href="https://github.com/rubenOrtz/Electrics-App" rel="noopener noreferrer"&gt;https://github.com/rubenOrtz/Electrics-App&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What do you think about bringing "Digital Twins" to mobile devices? Let's discuss in the comments!&lt;/p&gt;

&lt;h1&gt;
  
  
  flutter #dart #engineering #opensource #physics #programming
&lt;/h1&gt;

</description>
      <category>flutter</category>
      <category>engineering</category>
      <category>programming</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
