diff options
| author | victor | 2026-10-24 15:57:01 +0200 |
|---|---|---|
| committer | victor | 2026-10-24 15:57:01 +0200 |
| commit | 4533910bce394e7a0ee6debfc05ca1221ee51899 (patch) | |
| tree | 73aaa5b2c7a48dbf226e6b81d499ba1a8ecc33a1 /src/physics/test4.test.ts | |
| parent | Tilføj dansk (diff) | |
| download | 3D-Electrophysics-4533910bce394e7a0ee6debfc05ca1221ee51899.tar.gz 3D-Electrophysics-4533910bce394e7a0ee6debfc05ca1221ee51899.zip | |
Astra!ny-start
Diffstat (limited to '')
| -rw-r--r-- | src/physics/test4.test.ts | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/physics/test4.test.ts b/src/physics/test4.test.ts deleted file mode 100644 index 08dd868..0000000 --- a/src/physics/test4.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { describe, expect, it } from 'vitest'; -import { assembledEnergy, centralWork, dipoleState, energyTransfer, uniformWork } from './test4'; - -describe('Test 4 physical answers', () => { - it('uses only displacement along the uniform field and preserves the charge sign', () => { - expect(uniformWork(2e-9, 100, 3, Math.PI / 3)).toBeCloseTo(3e-7, 14); - expect(uniformWork(-2e-9, 100, 3, 0)).toBeCloseTo(-6e-7, 14); - expect(uniformWork(2e-9, 100, 3, Math.PI / 2)).toBeCloseTo(0, 14); - }); - it('computes point-charge work including the analytic infinity reference', () => { - expect(centralWork(3e-9, 2e-9, 2, 4)).toBeCloseTo(1.348132768845e-8, 16); - expect(centralWork(3e-9, -2e-9, 2, Infinity)).toBeCloseTo(-2.69626553769e-8, 16); - expect(() => centralWork(1, 1, 0, 2)).toThrow(RangeError); - }); - it('converts the potential drop to kinetic energy without changing total energy', () => { - const state = energyTransfer(3e-8, 1e-8, 5e-9, 1e-6); - expect(state.kinetic).toBeCloseTo(2.5e-8, 16); - expect(state.total).toBeCloseTo(3.5e-8, 16); - expect(state.speed).toBeCloseTo(0.22360679775, 10); - expect(() => energyTransfer(0, 1, 0, 1)).toThrow(RangeError); - }); - it('counts each pair once when building a charge configuration', () => { - const charges = [ - { x: 0, y: 0, z: 0, coulombs: 1e-9 }, - { x: 1, y: 0, z: 0, coulombs: 1e-9 }, - { x: 0, y: 0, z: 0.75, coulombs: -1e-9 }, - ]; - expect(assembledEnergy(charges.slice(0, 1))).toBe(0); - expect(assembledEnergy(charges)).toBeCloseTo(-1.0185892031273e-8, 16); - expect(() => assembledEnergy([charges[0], charges[0]])).toThrow(RangeError); - }); - it('distinguishes signed restoring torque, rotation work and zero at 90 degrees', () => { - const state = dipoleState(2e-9, 100, Math.PI / 2, 0); - expect(state.energy).toBeCloseTo(0, 14); - expect(state.torqueZ).toBeCloseTo(-2e-7, 14); - expect(state.work).toBeCloseTo(-2e-7, 14); - const aligned = dipoleState(2e-9, 100, 0, Math.PI / 2); - expect(aligned.energy).toBeCloseTo(-2e-7, 14); - expect(aligned.work).toBeCloseTo(2e-7, 14); - expect(dipoleState(2e-9, 100, Math.PI, 0).energy).toBeCloseTo(2e-7, 14); - }); -}); |