Add next calculators set with flow, magnetism, and EV conversions

This commit is contained in:
Codex Agent
2026-03-08 01:55:19 +00:00
parent e9e5adce42
commit 5e974ea9c7
4 changed files with 174 additions and 89 deletions

View File

@@ -1,5 +1,5 @@
// THIS FILE IS AUTO-GENERATED BY migrate.py
export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell';
export type CalcType = 'standard' | 'inverse' | '3col' | '3col-mul' | 'base' | 'text-bin' | 'bin-text' | 'dms-dd' | 'dd-dms' | 'dec-frac' | 'db-int' | 'db-spl' | 'db-v' | 'db-w' | 'awg' | 'brinell-rockwell' | 'ev-lux' | 'aov';
export interface CalculatorDef {
slug: string;
@@ -652,7 +652,7 @@ export const calculators: CalculatorDef[] = [
{"slug": "millimeters-to-microns", "name": "Millimeters to Microns", "category": "length", "type": "standard", "labels": {"in1": "Millimeters", "in2": "Microns"}, "factor": 1000.0},
{"slug": "femtograms-to-attograms", "name": "Femtograms to Attograms", "category": "weight", "type": "standard", "labels": {"in1": "Femtograms", "in2": "Attograms"}, "factor": 1000.0},
{"slug": "gigabytes-to-terabytes", "name": "Gigabytes to Terabytes", "category": "data", "type": "standard", "labels": {"in1": "Gigabytes", "in2": "Terabytes"}, "factor": 0.001},
{"slug": "maxwell-to-weber", "name": "Maxwell to Weber", "category": "magnetism", "type": "standard", "teaser": "Convert CGS magnetic flux (maxwell) into SI webers.", "labels": {"in1": "Maxwell", "in2": "Weber"}, "factor": 1e-08},
{"slug": "maxwell-to-weber", "name": "Maxwell to Weber", "category": "magnetism", "type": "standard", "teaser": "Convert CGS magnetic flux (maxwell) into SI webers.", "labels": {"in1": "Maxwell", "in2": "Weber"}, "factor": 1e-08, "hidden": true},
{"slug": "mbps-to-gbps", "name": "Mbps to Gbps", "category": "other", "type": "standard", "teaser": "Convert megabits per second into gigabits per second.", "labels": {"in1": "Mbps", "in2": "Gbps"}, "factor": 0.001, "hidden": true},
{"slug": "mbps-to-kbps", "name": "Mbps to Kbps", "category": "other", "type": "standard", "teaser": "Convert megabits per second into kilobits per second.", "labels": {"in1": "Mbps", "in2": "Kbps"}, "factor": 1000.0},
{"slug": "mbps-to-mb-per-second", "name": "Mbps to MB/s", "category": "other", "type": "standard", "teaser": "Convert megabits per second into megabytes per second.", "labels": {"in1": "Mbps", "in2": "MB/s"}, "factor": 0.125},
@@ -1598,11 +1598,44 @@ export const calculators: CalculatorDef[] = [
{"slug": "heat-transfer-coefficient-btu-per-hour-square-foot-f-to-w-per-square-meter-k", "name": "Heat transfer coefficient (BTU/(hr\u00b7ft\u00b2\u00b7\u00b0F)) to W/(m\u00b2\u00b7K)", "category": "energy", "type": "standard", "teaser": "Return imperial coefficients back into SI.", "labels": {"in1": "Heat transfer coefficient (BTU/(hr\u00b7ft\u00b2\u00b7\u00b0F))", "in2": "W/(m\u00b2\u00b7K)"}, "factor": 5.6782633415},
{"slug": "heat-transfer-coefficient-w-per-square-meter-k-to-w-per-square-foot-f", "name": "Heat transfer coefficient (W/(m\u00b2\u00b7K)) to W/(ft\u00b2\u00b7\u00b0F)", "category": "energy", "type": "standard", "teaser": "Move the conduction coefficient into mixed-area and temperature units.", "labels": {"in1": "Heat transfer coefficient (W/(m\u00b2\u00b7K))", "in2": "W/(ft\u00b2\u00b7\u00b0F)"}, "factor": 0.0516128},
{"slug": "heat-transfer-coefficient-w-per-square-foot-f-to-w-per-square-meter-k", "name": "Heat transfer coefficient (W/(ft\u00b2\u00b7\u00b0F)) to W/(m\u00b2\u00b7K)", "category": "energy", "type": "standard", "teaser": "Convert the mixed imperial SI coefficient back into its base units.", "labels": {"in1": "Heat transfer coefficient (W/(ft\u00b2\u00b7\u00b0F))", "in2": "W/(m\u00b2\u00b7K)"}, "factor": 19.3750387506},
{"slug": "ampere-turns-to-gilberts", "name": "Ampere-turns to Gilberts", "category": "magnetism", "type": "standard", "teaser": "Convert SI magnetomotive force into the CGS gilbert unit used for coils.", "labels": {"in1": "Ampere-turns", "in2": "Gilberts"}, "factor": 0.7957747155, "hidden": true},
{"slug": "gilberts-to-ampere-turns", "name": "Gilberts to Ampere-turns", "category": "magnetism", "type": "standard", "teaser": "Translate the historical gilbert into modern ampere-turns.", "labels": {"in1": "Gilberts", "in2": "Ampere-turns"}, "factor": 1.2566370614},
{"slug": "weber-to-maxwell", "name": "Weber to Maxwell", "category": "magnetism", "type": "standard", "teaser": "Translate SI magnetic flux into cgs maxwells.", "labels": {"in1": "Weber", "in2": "Maxwell"}, "factor": 100000000.0},
{"slug": "tesla-to-kilogauss", "name": "Tesla to Kilogauss", "category": "magnetism", "type": "standard", "teaser": "Translate tesla directly to kilogauss for chart comparisons.", "labels": {"in1": "Tesla", "in2": "Kilogauss"}, "factor": 10.0},
{"slug": "kilogauss-to-tesla", "name": "Kilogauss to Tesla", "category": "magnetism", "type": "standard", "teaser": "Return kilogauss values back into tesla.", "labels": {"in1": "Kilogauss", "in2": "Tesla"}, "factor": 0.1, "hidden": true},
{"slug": "cubic-meters-per-second-to-liters-per-minute", "name": "Cubic meters per second to Liters per minute", "category": "fluids", "type": "standard", "teaser": "Turn volumetric flow rates into convenient liters/minute values.", "labels": {"in1": "Cubic meters per second", "in2": "Liters per minute"}, "factor": 60000.0},
{"slug": "kilograms-per-second-to-pounds-per-hour", "name": "Kilograms per second to Pounds per hour", "category": "weight", "type": "standard", "teaser": "Convert mass flow from the SI kilogram scale to imperial pounds per hour.", "labels": {"in1": "Kilograms per second", "in2": "Pounds per hour"}, "factor": 7936.641761},
{"slug": "pounds-per-hour-to-kilograms-per-second", "name": "Pounds per hour to Kilograms per second", "category": "weight", "type": "standard", "teaser": "Bring imperial mass flow back into the SI kilogram rate.", "labels": {"in1": "Pounds per hour", "in2": "Kilograms per second"}, "factor": 0.000126577, "hidden": true},
{"slug": "moles-per-second-to-moles-per-hour", "name": "Moles per second to Moles per hour", "category": "other", "type": "standard", "teaser": "Translate molar flow between seconds and hours.", "labels": {"in1": "Moles per second", "in2": "Moles per hour"}, "factor": 3600.0},
{"slug": "moles-per-hour-to-moles-per-second", "name": "Moles per hour to Moles per second", "category": "other", "type": "standard", "teaser": "Return molar flow rates back to per-second units.", "labels": {"in1": "Moles per hour", "in2": "Moles per second"}, "factor": 0.0002777778, "hidden": true},
{"slug": "kilograms-per-second-per-square-meter-to-grams-per-second-per-square-centimeter", "name": "Kilograms per second per square meter to Grams per second per square centimeter", "category": "other", "type": "standard", "teaser": "Express mass flux density using metric subunits.", "labels": {"in1": "Kilograms per second per square meter", "in2": "Grams per second per square centimeter"}, "factor": 0.1, "hidden": true},
{"slug": "grams-per-second-per-square-centimeter-to-kilograms-per-second-per-square-meter", "name": "Grams per second per square centimeter to Kilograms per second per square meter", "category": "other", "type": "standard", "teaser": "Convert compact mass flux into the SI-friendly base.", "labels": {"in1": "Grams per second per square centimeter", "in2": "Kilograms per second per square meter"}, "factor": 10.0},
{"slug": "mol-per-cubic-meter-to-mmol-per-liter", "name": "Mol per cubic meter to mmol per liter", "category": "fluids", "type": "standard", "teaser": "Translate molar concentrations across common volume units.", "labels": {"in1": "Mol per cubic meter", "in2": "mmol per liter"}, "hidden": true},
{"slug": "mmol-per-liter-to-mol-per-cubic-meter", "name": "mmol per liter to mol per cubic meter", "category": "fluids", "type": "standard", "teaser": "Convert molar concentration back into SI cubic meters.", "labels": {"in1": "mmol per liter", "in2": "mol per cubic meter"}},
{"slug": "percent-by-mass-to-ppm", "name": "Percent by mass to ppm", "category": "other", "type": "standard", "teaser": "Turn mass-percent concentrations into parts-per-million.", "labels": {"in1": "Percent by mass", "in2": "ppm"}, "factor": 10000.0},
{"slug": "ppm-to-percent-by-mass", "name": "ppm to Percent by mass", "category": "other", "type": "standard", "teaser": "Return ppm values to mass-percent.", "labels": {"in1": "ppm", "in2": "Percent by mass"}, "factor": 0.0001, "hidden": true},
{"slug": "pascal-second-to-poise", "name": "Pascal-second to Poise", "category": "pressure", "type": "standard", "teaser": "Convert SI dynamic viscosity into CGS poise.", "labels": {"in1": "Pascal-second", "in2": "Poise"}, "factor": 10.0},
{"slug": "poise-to-pascal-second", "name": "Poise to Pascal-second", "category": "pressure", "type": "standard", "teaser": "Bring poise measurements back into pascal-seconds.", "labels": {"in1": "Poise", "in2": "Pascal-second"}, "factor": 0.1, "hidden": true},
{"slug": "pascal-second-to-centipoise", "name": "Pascal-second to Centipoise", "category": "pressure", "type": "standard", "teaser": "Express pascal-seconds as centipoise for lab viscosity.", "labels": {"in1": "Pascal-second", "in2": "Centipoise"}, "factor": 100.0},
{"slug": "centipoise-to-pascal-second", "name": "Centipoise to Pascal-second", "category": "pressure", "type": "standard", "teaser": "Convert centipoise into pascal-seconds.", "labels": {"in1": "Centipoise", "in2": "Pascal-second"}, "factor": 0.01, "hidden": true},
{"slug": "square-meter-per-second-to-centistokes", "name": "Square meter per second to Centistokes", "category": "other", "type": "standard", "teaser": "Translate kinematic viscosity into centistokes.", "labels": {"in1": "Square meter per second", "in2": "Centistokes"}, "factor": 100.0},
{"slug": "centistokes-to-square-meter-per-second", "name": "Centistokes to Square meter per second", "category": "other", "type": "standard", "teaser": "Return centistokes back to base square meters per second.", "labels": {"in1": "Centistokes", "in2": "Square meter per second"}, "factor": 0.01, "hidden": true},
{"slug": "newton-per-meter-to-dyne-per-centimeter", "name": "Newton per meter to Dyne per centimeter", "category": "force", "type": "standard", "teaser": "Express surface tension on the CGS scale.", "labels": {"in1": "Newton per meter", "in2": "Dyne per centimeter"}, "factor": 1000.0},
{"slug": "dyne-per-centimeter-to-newton-per-meter", "name": "Dyne per centimeter to Newton per meter", "category": "force", "type": "standard", "teaser": "Convert surface tension back into SI.", "labels": {"in1": "Dyne per centimeter", "in2": "Newton per meter"}, "factor": 0.001, "hidden": true},
{"slug": "henry-per-meter-to-tesla-meter-per-ampere", "name": "Henry per meter to Tesla-meter per ampere", "category": "magnetism", "type": "standard", "teaser": "Equate magnetic permeability units across SI conventions.", "labels": {"in1": "Henry per meter", "in2": "Tesla-meter per ampere"}},
{"slug": "tesla-meter-per-ampere-to-henry-per-meter", "name": "Tesla-meter per ampere to Henry per meter", "category": "magnetism", "type": "standard", "teaser": "Return permeability back to henry per meter.", "labels": {"in1": "Tesla-meter per ampere", "in2": "Henry per meter"}, "hidden": true},
{"slug": "awg-to-circular-mils", "name": "AWG to Circular mils", "category": "electrical", "type": "awg", "teaser": "Convert American Wire Gauge sizes into circular mil areas.", "labels": {"in1": "AWG", "in2": "Circular mils"}},
{"slug": "awg-to-millimeters-diameter", "name": "AWG to Millimeters (diameter)", "category": "electrical", "type": "awg", "teaser": "Express AWG gauge as a diameter in millimeters.", "labels": {"in1": "AWG", "in2": "Millimeters (diameter)"}},
{"slug": "awg-to-square-millimeters-cross-section", "name": "AWG to Square millimeters (cross-section)", "category": "electrical", "type": "awg", "teaser": "Convert AWG sizes into cross-sectional area in mm\u00b2.", "labels": {"in1": "AWG", "in2": "Square millimeters (cross-section)"}},
{"slug": "board-feet-energy-equiv-to-btu", "name": "Board feet (energy equiv.) to BTU", "category": "energy", "type": "standard", "teaser": "Convert the energy equivalent of a board foot of lumber into BTUs.", "labels": {"in1": "Board feet (energy equiv.)", "in2": "BTU"}, "factor": 14000.0},
{"slug": "brinell-to-rockwell-c", "name": "Brinell to Rockwell C", "category": "other", "type": "brinell-rockwell", "teaser": "Approximate Rockwell C hardness from Brinell hardness numbers.", "labels": {"in1": "Brinell", "in2": "Rockwell C"}},
{"slug": "cloves-to-kilograms", "name": "Cloves to Kilograms", "category": "weight", "type": "standard", "teaser": "Convert traditional clove mass into kilograms.", "labels": {"in1": "Cloves", "in2": "Kilograms"}, "factor": 3.62873896},
{"slug": "em-to-pixels", "name": "Em to Pixels", "category": "other", "type": "standard", "teaser": "Convert CSS em units to pixels assuming a 16px base size.", "labels": {"in1": "Em", "in2": "Pixels"}, "factor": 16.0},
{"slug": "ev-to-lux", "name": "EV (exposure value) to Lux", "category": "light", "type": "ev-lux", "teaser": "Estimate scene illuminance at ISO 100.", "labels": {"in1": "EV (exposure value)", "in2": "Lux"}},
{"slug": "lux-to-ev", "name": "Lux to EV", "category": "light", "type": "ev-lux", "teaser": "Convert lux readings to exposure value at ISO 100.", "labels": {"in1": "Lux", "in2": "EV"}, "hidden": true},
{"slug": "f-stops-to-t-stops", "name": "f-stops to T-stops", "category": "other", "type": "standard", "teaser": "Treat f-number as t-stop under ideal transmission.", "labels": {"in1": "f-stops", "in2": "T-stops"}},
{"slug": "focal-length-to-angle-of-view", "name": "Focal length to Angle of view", "category": "other", "type": "aov", "teaser": "Approximate horizontal angle on 35mm full-frame (36mm width).", "labels": {"in1": "Focal length", "in2": "Angle of view"}},
{"slug": "millimeters-to-awg", "name": "Millimeters to AWG", "category": "electrical", "type": "awg", "teaser": "Convert conductor diameter in millimeters to AWG gauge.", "labels": {"in1": "Millimeters", "in2": "AWG"}},
];

View File

@@ -199,30 +199,71 @@ export function solve(
const slug = calc.slug;
const formatAwg = (g: number) => isFinite(g) ? fmt(g) : '';
const awgIsInput = calc.labels.in1.toLowerCase().includes('awg');
const isCircular = slug.includes('circular-mils');
const isArea = slug.includes('square-millimeters');
if (slug.includes('circular-mils')) {
if (source === 1) {
out.val2 = !isNaN(v1) ? fmt(awgToCircularMils(v1)) : '';
if (isCircular) {
if (awgIsInput) {
if (source === 1) out.val2 = !isNaN(v1) ? fmt(awgToCircularMils(v1)) : '';
else out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(circularMilsToAwg(v2)) : '';
} else {
out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(circularMilsToAwg(v2)) : '';
if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? formatAwg(circularMilsToAwg(v1)) : '';
else out.val1 = !isNaN(v2) ? fmt(awgToCircularMils(v2)) : '';
}
} else if (slug.includes('square-millimeters')) {
if (source === 1) {
out.val2 = !isNaN(v1) ? fmt(awgToAreaMm2(v1)) : '';
} else if (isArea) {
if (awgIsInput) {
if (source === 1) out.val2 = !isNaN(v1) ? fmt(awgToAreaMm2(v1)) : '';
else out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(areaMm2ToAwg(v2)) : '';
} else {
out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(areaMm2ToAwg(v2)) : '';
if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? formatAwg(areaMm2ToAwg(v1)) : '';
else out.val1 = !isNaN(v2) ? fmt(awgToAreaMm2(v2)) : '';
}
} else {
// diameter in millimeters
if (source === 1) {
out.val2 = !isNaN(v1) ? fmt(awgToDiameterMm(v1)) : '';
if (awgIsInput) {
if (source === 1) out.val2 = !isNaN(v1) ? fmt(awgToDiameterMm(v1)) : '';
else out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(diameterMmToAwg(v2)) : '';
} else {
out.val1 = (!isNaN(v2) && v2 > 0) ? formatAwg(diameterMmToAwg(v2)) : '';
if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? formatAwg(diameterMmToAwg(v1)) : '';
else out.val1 = !isNaN(v2) ? fmt(awgToDiameterMm(v2)) : '';
}
}
break;
}
case 'ev-lux': {
const isEvFirst = calc.labels.in1.toLowerCase().includes('ev');
const toLux = (ev: number) => 2.5 * Math.pow(2, ev);
const toEv = (lux: number) => lux > 0 ? Math.log(lux / 2.5) / Math.log(2) : NaN;
if (isEvFirst) {
if (source === 1) out.val2 = !isNaN(v1) ? fmt(toLux(v1)) : '';
else out.val1 = (!isNaN(v2) && v2 > 0) ? fmt(toEv(v2)) : '';
} else {
if (source === 1) out.val2 = (!isNaN(v1) && v1 > 0) ? fmt(toEv(v1)) : '';
else out.val1 = !isNaN(v2) ? fmt(toLux(v2)) : '';
}
break;
}
case 'aov': {
const sensorWidth = 36; // mm, full-frame horizontal
const isFocalFirst = calc.labels.in1.toLowerCase().includes('focal');
const toAov = (f: number) => f > 0 ? (2 * Math.atan(sensorWidth / (2 * f)) * 180 / Math.PI) : NaN;
const toFocal = (angle: number) => {
const radians = angle * Math.PI / 180;
return Math.tan(radians / 2) !== 0 ? sensorWidth / (2 * Math.tan(radians / 2)) : NaN;
};
if (isFocalFirst) {
if (source === 1) out.val2 = (!isNaN(v1) && v1 !== 0) ? fmt(toAov(v1)) : '';
else out.val1 = (!isNaN(v2) && v2 !== 0) ? fmt(toFocal(v2)) : '';
} else {
if (source === 1) out.val2 = (!isNaN(v1) && v1 !== 0) ? fmt(toFocal(v1)) : '';
else out.val1 = (!isNaN(v2) && v2 !== 0) ? fmt(toAov(v2)) : '';
}
break;
}
case 'brinell-rockwell': {
// Approximate correlation for steels:
// BHN = (1520000 - 4500 * HRC) / (100 - HRC)^2