Spaces:
Running
Running
| /** | |
| * Training Stress Score (TSS) Calculator | |
| * | |
| * TSS is a concept developed by Andrew Coggan to quantify the physiological | |
| * load and fatigue of a given training session, taking into account both | |
| * its duration and intensity. | |
| * | |
| * Formula for running: | |
| * TSS = (t × NP × IF) / (FTP × 3600) × 100 | |
| * | |
| * Where: | |
| * - t: Duration of activity in seconds | |
| * - NP (Normalized Power®): Power you could have maintained if effort was perfectly regular | |
| * - IF (Intensity Factor): NP / FTP | |
| * - FTP (Functional Threshold Power): Maximum power you can maintain for about 1 hour | |
| * - 3600: Conversion of one hour to seconds | |
| * | |
| * In practice: | |
| * - TSS = 100: represents 1 hour at threshold intensity (FTP) | |
| * - TSS < 100: easy or moderate training | |
| * - TSS > 100: very long or very intense training | |
| */ | |
| export interface TSSInputs { | |
| durationSeconds: number; | |
| normalizedPower?: number; // NP in watts | |
| ftp?: number; // Functional Threshold Power in watts | |
| } | |
| /** | |
| * Calculate Training Stress Score (TSS) | |
| * | |
| * @param inputs - Duration, Normalized Power, and FTP | |
| * @returns TSS value or undefined if required data is missing | |
| */ | |
| export function calculateTSS(inputs: TSSInputs): number | undefined { | |
| const { durationSeconds, normalizedPower, ftp } = inputs; | |
| // Need all three values to calculate TSS | |
| if (!normalizedPower || !ftp || ftp === 0) { | |
| return undefined; | |
| } | |
| // IF (Intensity Factor) = NP / FTP | |
| const intensityFactor = normalizedPower / ftp; | |
| // TSS = (t × NP × IF) / (FTP × 3600) × 100 | |
| const tss = (durationSeconds * normalizedPower * intensityFactor) / (ftp * 3600) * 100; | |
| return tss; | |
| } | |