From 9ad0c23decbfecf4c2a0b39b8f79e67cd43ba1f0 Mon Sep 17 00:00:00 2001
From: Jon Rasmussen <144543309+jonrack77@users.noreply.github.com>
Date: Wed, 19 Nov 2025 10:58:15 -0800
Subject: [PATCH 1/5] Remove debug slider and keep inertia code-configurable
---
Script.js | 114 ++++++++++++++++++++++++++++-------------------------
index.html | 53 +++----------------------
2 files changed, 66 insertions(+), 101 deletions(-)
diff --git a/Script.js b/Script.js
index b274203..505debf 100644
--- a/Script.js
+++ b/Script.js
@@ -231,19 +231,23 @@ function angleOf(id){
/* ///////////// Section 5 — Simulator Core (IIFE) ///////////// */
(function(){
/* ///////////// Section 5.A Rated constants (RATED) ///////////// */
- const RATED = {
- KV_LL: 13.8, // kV line-line nominal
- MVA: 25, // MVA rating
- MW: 23.5, // continuous MW
- MVAR_LAG_MAX: 15.5, // +Q
- MVAR_LEAD_MAX: 19.4, // -Q
- AMPS: 1046.9 // at 13.8kV
- };
-
- /* ///////////// Section 5.B State object (state) + exposure ///////////// */
-const state = {
- Master_Started:false,
- AVR_On:false,
+ const RATED = {
+ KV_LL: 13.8, // kV line-line nominal
+ MVA: 25, // MVA rating
+ MW: 23.5, // continuous MW
+ MVAR_LAG_MAX: 15.5, // +Q
+ MVAR_LEAD_MAX: 19.4, // -Q
+ AMPS: 1046.9 // at 13.8kV
+ };
+
+ // Inertia: higher values slow both acceleration and deceleration when off-grid.
+ // Tune by changing the numeric constant below—no UI controls adjust this value.
+ const INERTIA_TIME_CONST_S = 1.5;
+
+ /* ///////////// Section 5.B State object (state) + exposure ///////////// */
+const state = {
+ Master_Started:false,
+ AVR_On:false,
Sync_On:false,
// Latches TRUE when 52G closes; does NOT auto-unlatch on open
@@ -261,17 +265,18 @@ const state = {
SyncCheck_Perm_Var:false,
// Bus references
- Bus_Freq_Hz:60,
- Bus_Voltage_kV:13.8,
-
- // Voltage model
- Gen_kV_Var:0, // actual terminal kV “inside the 52G”
- Gen_kV_SP:13.5, // operator/AVR setpoint (kV)
-
- // Power model
- MW:0,
- MVAR:0,
- AMPS:0,
+ Bus_Freq_Hz:60,
+ Bus_Voltage_kV:13.8,
+
+ // Voltage model
+ Gen_kV_Var:0, // actual terminal kV “inside the 52G”
+ Gen_kV_SP:13.5, // operator/AVR setpoint (kV)
+
+ // Governor/gate dynamics
+ // Power model
+ MW:0,
+ MVAR:0,
+ AMPS:0,
PF:0
};
try{ window.SimState = state; }catch(_){}
@@ -302,12 +307,8 @@ const FREQ_GATE_THRESH_PCT = 20; // gate % breakpoint for frequency
const FREQ_GATE_LOW_HZ_PER_PCT = 3; // Hz per % gate below threshold
const FREQ_GATE_HIGH_HZ_PER_PCT = 0.375; // Hz per % gate above threshold
const FREQ_GATE_HIGH_INTERCEPT_HZ = 52.5; // offset for high range
-const FREQ_DECEL_HZ_S = 3; // fixed fall rate (Hz/s) when raw < current
-const FREQ_DECEL_SLOW_THRESH_HZ = 20; // Hz threshold to slow decel
-const FREQ_DECEL_SLOW_HZ_S = FREQ_DECEL_HZ_S / .25; // half-rate below threshold
-
-// AVR line-drop compensation (disabled if 0)
-const AVR_LDC_PU = 0.00;
+// AVR line-drop compensation (disabled if 0)
+const AVR_LDC_PU = 0.00;
// Power mapping: physical gate needed for ~0 MW when paralleled
const NO_LOAD_GATE_PCT = 20; // set near your sync gate (e.g., 18–20)
@@ -866,29 +867,36 @@ function updatePhysics(){
if (state['41_Brk_Var']) handleAction('41_OPEN');
}
- /// Frequency (single-owner slew): on-grid=60; off-grid rises follow gate; falls decay at fixed rate
- {
- const onGrid = !!state['52G_Brk_Var'];
- let raw;
- if (onGrid) {
- raw = 60;
- } else {
- const gate = state.Gate_Pos_Var;
- raw = (gate <= FREQ_GATE_THRESH_PCT)
- ? FREQ_GATE_LOW_HZ_PER_PCT * gate
- : (FREQ_GATE_HIGH_HZ_PER_PCT * gate + FREQ_GATE_HIGH_INTERCEPT_HZ);
- }
- const curr = +state.Gen_Freq_Var || 0;
- const dt_s = Math.max(0, dt) / 1000;
-
- const decelRate = (curr > FREQ_DECEL_SLOW_THRESH_HZ)
- ? FREQ_DECEL_HZ_S
- : FREQ_DECEL_SLOW_HZ_S;
-
- const next = (raw >= curr) ? raw : Math.max(raw, curr - decelRate * dt_s);
-
- state.Gen_Freq_Var = clamp(next, 0, 94);
- state.Gen_RPM_Var = state.Gen_Freq_Var * 1.667;
+ /// Frequency (single-owner slew): on-grid=60; off-grid ramps toward gate-implied speed using inertia
+ {
+ const onGrid = !!state['52G_Brk_Var'];
+ let raw;
+ if (onGrid) {
+ raw = 60;
+ } else {
+ const gate = state.Gate_Pos_Var;
+ raw = (gate <= FREQ_GATE_THRESH_PCT)
+ ? FREQ_GATE_LOW_HZ_PER_PCT * gate
+ : (FREQ_GATE_HIGH_HZ_PER_PCT * gate + FREQ_GATE_HIGH_INTERCEPT_HZ);
+ }
+ const curr = +state.Gen_Freq_Var || 0;
+ const dt_s = Math.max(0, dt) / 1000;
+
+ let next;
+ if (onGrid) {
+ next = raw;
+ } else {
+ const inertia = INERTIA_TIME_CONST_S;
+ const step = (raw - curr) * (dt_s / inertia);
+ next = curr + step;
+ // Avoid overshoot when the step would cross the target
+ if (Math.sign(raw - curr) !== Math.sign(raw - next)) {
+ next = raw;
+ }
+ }
+
+ state.Gen_Freq_Var = clamp(next, 0, 94);
+ state.Gen_RPM_Var = state.Gen_Freq_Var * 1.667;
// Log major stopping events based on frequency thresholds
if (!state['52G_Brk_Var'] && state.Master_Started && curr > state.Gen_Freq_Var) {
diff --git a/index.html b/index.html
index d6e7ca3..65b096f 100644
--- a/index.html
+++ b/index.html
@@ -98,12 +98,6 @@
Hydroelectric Generator Synchronization S
-
-
-
-
-
-
-
+
From ef4b7809c47f742a4f56908d305095c5c2e2215c Mon Sep 17 00:00:00 2001
From: Jon Rasmussen <144543309+jonrack77@users.noreply.github.com>
Date: Wed, 19 Nov 2025 11:30:47 -0800
Subject: [PATCH 5/5] Restore original code state
---
index.html => Index.html.html | 618 ++++++-----
Scipt.js | 1753 ++++++++++++++++++++++++++++++
Script.js | 1907 ---------------------------------
Sim_Manual.pdf | Bin 83948 -> 0 bytes
googled9d1eff3cee3f7bb.html | 1 -
netlify.toml | 24 -
readme.md | 16 -
robots.txt | 5 -
sitemap.txt | 8 -
sitemap.xml | 9 -
sitemap_index.xml | 7 -
yandex_4c440f91da05aaad.html | 6 -
12 files changed, 2129 insertions(+), 2225 deletions(-)
rename index.html => Index.html.html (96%)
create mode 100644 Scipt.js
delete mode 100644 Script.js
delete mode 100644 Sim_Manual.pdf
delete mode 100644 googled9d1eff3cee3f7bb.html
delete mode 100644 netlify.toml
delete mode 100644 readme.md
delete mode 100644 robots.txt
delete mode 100644 sitemap.txt
delete mode 100644 sitemap.xml
delete mode 100644 sitemap_index.xml
delete mode 100644 yandex_4c440f91da05aaad.html
diff --git a/index.html b/Index.html.html
similarity index 96%
rename from index.html
rename to Index.html.html
index e42f95e..84bf47a 100644
--- a/index.html
+++ b/Index.html.html
@@ -1,61 +1,16 @@
-
-
-
- Generator Synchroscope (Syncroscope) Simulator | Hydroelectric Grid Sync Trainer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+SyncroScope_Simulator
-
- Hydroelectric Generator Synchronization Simulator
-
-
-
+ ry="5.1065636" />
+
+
+
+
+
+
+
+
+
-
+ requestAnimationFrame(syncFromArea);
+ }
+
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', install, {once:true});
+ else install();
+})();
+