@@ -39,15 +39,15 @@ void analyticalUnderdamped() {
3939 double gamma = 0.5 ;
4040 DampedOscillator d = new DampedOscillator (omega0 , gamma );
4141
42- double A = 1.0 ;
42+ double a = 1.0 ;
4343 double phi = 0.2 ;
4444 double t = 0.123 ;
4545
46- // expected: A * exp(-gamma * t) * cos(omega_d * t + phi)
46+ // expected: a * exp(-gamma * t) * cos(omega_d * t + phi)
4747 double omegaD = Math .sqrt (Math .max (0.0 , omega0 * omega0 - gamma * gamma ));
48- double expected = A * Math .exp (-gamma * t ) * Math .cos (omegaD * t + phi );
48+ double expected = a * Math .exp (-gamma * t ) * Math .cos (omegaD * t + phi );
4949
50- double actual = d .displacementAnalytical (A , phi , t );
50+ double actual = d .displacementAnalytical (a , phi , t );
5151 assertEquals (expected , actual , 1e-12 , "Analytical underdamped displacement should match closed-form value" );
5252 }
5353
@@ -58,13 +58,13 @@ void analyticalOverdamped() {
5858 double gamma = 2.0 ; // gamma > omega0 => omega_d = 0 in our implementation (Math.max)
5959 DampedOscillator d = new DampedOscillator (omega0 , gamma );
6060
61- double A = 2.0 ;
61+ double a = 2.0 ;
6262 double phi = Math .PI / 4.0 ;
6363 double t = 0.5 ;
6464
6565 // With omegaD forced to 0 by implementation, expected simplifies to:
66- double expected = A * Math .exp (-gamma * t ) * Math .cos (phi );
67- double actual = d .displacementAnalytical (A , phi , t );
66+ double expected = a * Math .exp (-gamma * t ) * Math .cos (phi );
67+ double actual = d .displacementAnalytical (a , phi , t );
6868
6969 assertEquals (expected , actual , 1e-12 , "Overdamped handling should reduce to exponential * cos(phase)" );
7070 }
@@ -76,14 +76,14 @@ void eulerApproximatesAnalyticalSmallDt() {
7676 double gamma = 0.5 ;
7777 DampedOscillator d = new DampedOscillator (omega0 , gamma );
7878
79- double A = 1.0 ;
79+ double a = 1.0 ;
8080 double phi = 0.0 ;
8181
82- // initial conditions consistent with amplitude A and zero phase:
83- // x(0) = A , v(0) = -A * gamma * cos(phi) + A * omegaD * sin(phi)
82+ // initial conditions consistent with amplitude a and zero phase:
83+ // x(0) = a , v(0) = -a * gamma * cos(phi) + a * omegaD * sin(phi)
8484 double omegaD = Math .sqrt (Math .max (0.0 , omega0 * omega0 - gamma * gamma ));
85- double x0 = A * Math .cos (phi );
86- double v0 = -A * gamma * Math .cos (phi ) - A * omegaD * Math .sin (phi ); // small general form
85+ double x0 = a * Math .cos (phi );
86+ double v0 = -a * gamma * Math .cos (phi ) - a * omegaD * Math .sin (phi ); // small general form
8787
8888 double dt = 1e-4 ;
8989 int steps = 1000 ; // simulate to t = 0.1s
@@ -94,7 +94,7 @@ void eulerApproximatesAnalyticalSmallDt() {
9494 state = d .stepEuler (state , dt );
9595 }
9696
97- double analyticAtT = d .displacementAnalytical (A , phi , tFinal );
97+ double analyticAtT = d .displacementAnalytical (a , phi , tFinal );
9898 double numericAtT = state [0 ];
9999
100100 // Euler is low-order — allow a small tolerance but assert it remains close for small dt + short time.
@@ -131,13 +131,13 @@ void analyticalAtZeroTime() {
131131 double gamma = 0.2 ;
132132 DampedOscillator d = new DampedOscillator (omega0 , gamma );
133133
134- double A = 2.0 ;
134+ double a = 2.0 ;
135135 double phi = Math .PI / 3.0 ;
136136 double t = 0.0 ;
137137
138- double expected = A * Math .cos (phi );
139- double actual = d .displacementAnalytical (A , phi , t );
138+ double expected = a * Math .cos (phi );
139+ double actual = d .displacementAnalytical (a , phi , t );
140140
141- assertEquals (expected , actual , 1e-12 , "Displacement at t=0 should be A * cos(phase)" );
141+ assertEquals (expected , actual , 1e-12 , "Displacement at t=0 should be a * cos(phase)" );
142142 }
143143}
0 commit comments