mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-14 17:14:02 +01:00
Wire gauge calc
This commit is contained in:
@@ -1,62 +0,0 @@
|
|||||||
export default {
|
|
||||||
title: 'American Wire Gauge',
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
diameter: {
|
|
||||||
title: 'Diameter',
|
|
||||||
type: 'number',
|
|
||||||
unit: 'mm'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
data: {
|
|
||||||
'0000': { diameter: 11.684 },
|
|
||||||
'000': { diameter: 10.405 },
|
|
||||||
'00': { diameter: 9.266 },
|
|
||||||
'0': { diameter: 8.251 },
|
|
||||||
'(4/0)': { diameter: 11.684 },
|
|
||||||
'(3/0)': { diameter: 10.405 },
|
|
||||||
'(2/0)': { diameter: 9.266 },
|
|
||||||
'(1/0)': { diameter: 8.251 },
|
|
||||||
'1': { diameter: 7.348 },
|
|
||||||
'2': { diameter: 6.544 },
|
|
||||||
'3': { diameter: 5.827 },
|
|
||||||
'4': { diameter: 5.189 },
|
|
||||||
'5': { diameter: 4.621 },
|
|
||||||
'6': { diameter: 4.115 },
|
|
||||||
'7': { diameter: 3.665 },
|
|
||||||
'8': { diameter: 3.264 },
|
|
||||||
'9': { diameter: 2.906 },
|
|
||||||
'10': { diameter: 2.588 },
|
|
||||||
'11': { diameter: 2.305 },
|
|
||||||
'12': { diameter: 2.053 },
|
|
||||||
'13': { diameter: 1.828 },
|
|
||||||
'14': { diameter: 1.628 },
|
|
||||||
'15': { diameter: 1.45 },
|
|
||||||
'16': { diameter: 1.291 },
|
|
||||||
'17': { diameter: 1.15 },
|
|
||||||
'18': { diameter: 1.024 },
|
|
||||||
'19': { diameter: 0.912 },
|
|
||||||
'20': { diameter: 0.812 },
|
|
||||||
'21': { diameter: 0.723 },
|
|
||||||
'22': { diameter: 0.644 },
|
|
||||||
'23': { diameter: 0.573 },
|
|
||||||
'24': { diameter: 0.511 },
|
|
||||||
'25': { diameter: 0.455 },
|
|
||||||
'26': { diameter: 0.405 },
|
|
||||||
'27': { diameter: 0.361 },
|
|
||||||
'28': { diameter: 0.321 },
|
|
||||||
'29': { diameter: 0.286 },
|
|
||||||
'30': { diameter: 0.255 },
|
|
||||||
'31': { diameter: 0.227 },
|
|
||||||
'32': { diameter: 0.202 },
|
|
||||||
'33': { diameter: 0.18 },
|
|
||||||
'34': { diameter: 0.16 },
|
|
||||||
'35': { diameter: 0.143 },
|
|
||||||
'36': { diameter: 0.127 },
|
|
||||||
'37': { diameter: 0.113 },
|
|
||||||
'38': { diameter: 0.101 },
|
|
||||||
'39': { diameter: 0.0897 },
|
|
||||||
'40': { diameter: 0.0799 }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,3 +1,10 @@
|
|||||||
export const allDataTables: { [key: string]: { [key: string]: any } } = {
|
import type { DataTable } from '../types';
|
||||||
'american-wire-gauge': {}
|
import wiregauge from './wire_gauge';
|
||||||
|
import material_electrical_properties from './material_electrical_properties';
|
||||||
|
|
||||||
|
const allDataTables: { [key: string]: DataTable } = {
|
||||||
|
'wire-gauge': wiregauge,
|
||||||
|
'material-electrical-properties': material_electrical_properties
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default allDataTables;
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
data: {
|
data: {
|
||||||
copper: {
|
Copper: {
|
||||||
resistivity: 1.68e-8
|
resistivity_20c: 1.68e-8
|
||||||
},
|
},
|
||||||
aluminum: {
|
Aluminum: {
|
||||||
resistivity: 2.82e-8
|
resistivity_20c: 2.82e-8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
75
src/datatables/data/wire_gauge.ts
Normal file
75
src/datatables/data/wire_gauge.ts
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import type { DataTable } from '../types';
|
||||||
|
|
||||||
|
const data: DataTable = {
|
||||||
|
title: 'American Wire Gauge',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
diameter: {
|
||||||
|
title: 'Diameter',
|
||||||
|
type: 'number',
|
||||||
|
unit: 'mm'
|
||||||
|
},
|
||||||
|
area: {
|
||||||
|
title: 'Area',
|
||||||
|
type: 'number',
|
||||||
|
unit: 'mm^2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
data: {
|
||||||
|
'0000 AWG': { diameter: 11.684 },
|
||||||
|
'000 AWG': { diameter: 10.405 },
|
||||||
|
'00 AWG': { diameter: 9.266 },
|
||||||
|
'0 AWG': { diameter: 8.251 },
|
||||||
|
'(4/0) AWG': { diameter: 11.684 },
|
||||||
|
'(3/0) AWG': { diameter: 10.405 },
|
||||||
|
'(2/0) AWG': { diameter: 9.266 },
|
||||||
|
'(1/0) AWG': { diameter: 8.251 },
|
||||||
|
'1 AWG': { diameter: 7.348 },
|
||||||
|
'2 AWG': { diameter: 6.544 },
|
||||||
|
'3 AWG': { diameter: 5.827 },
|
||||||
|
'4 AWG': { diameter: 5.189 },
|
||||||
|
'5 AWG': { diameter: 4.621 },
|
||||||
|
'6 AWG': { diameter: 4.115 },
|
||||||
|
'7 AWG': { diameter: 3.665 },
|
||||||
|
'8 AWG': { diameter: 3.264 },
|
||||||
|
'9 AWG': { diameter: 2.906 },
|
||||||
|
'10 AWG': { diameter: 2.588 },
|
||||||
|
'11 AWG': { diameter: 2.305 },
|
||||||
|
'12 AWG': { diameter: 2.053 },
|
||||||
|
'13 AWG': { diameter: 1.828 },
|
||||||
|
'14 AWG': { diameter: 1.628 },
|
||||||
|
'15 AWG': { diameter: 1.45 },
|
||||||
|
'16 AWG': { diameter: 1.291 },
|
||||||
|
'17 AWG': { diameter: 1.15 },
|
||||||
|
'18 AWG': { diameter: 1.024 },
|
||||||
|
'19 AWG': { diameter: 0.912 },
|
||||||
|
'20 AWG': { diameter: 0.812 },
|
||||||
|
'21 AWG': { diameter: 0.723 },
|
||||||
|
'22 AWG': { diameter: 0.644 },
|
||||||
|
'23 AWG': { diameter: 0.573 },
|
||||||
|
'24 AWG': { diameter: 0.511 },
|
||||||
|
'25 AWG': { diameter: 0.455 },
|
||||||
|
'26 AWG': { diameter: 0.405 },
|
||||||
|
'27 AWG': { diameter: 0.361 },
|
||||||
|
'28 AWG': { diameter: 0.321 },
|
||||||
|
'29 AWG': { diameter: 0.286 },
|
||||||
|
'30 AWG': { diameter: 0.255 },
|
||||||
|
'31 AWG': { diameter: 0.227 },
|
||||||
|
'32 AWG': { diameter: 0.202 },
|
||||||
|
'33 AWG': { diameter: 0.18 },
|
||||||
|
'34 AWG': { diameter: 0.16 },
|
||||||
|
'35 AWG': { diameter: 0.143 },
|
||||||
|
'36 AWG': { diameter: 0.127 },
|
||||||
|
'37 AWG': { diameter: 0.113 },
|
||||||
|
'38 AWG': { diameter: 0.101 },
|
||||||
|
'39 AWG': { diameter: 0.0897 },
|
||||||
|
'40 AWG': { diameter: 0.0799 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const key in data.data) {
|
||||||
|
data.data[key].area = Math.PI * data.data[key].diameter ** 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default data;
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
import type { DataTable } from './types.ts';
|
import type { DataTable } from './types.ts';
|
||||||
import { allDataTables } from './data/index';
|
|
||||||
|
|
||||||
export async function getDataTable(name: string): Promise<DataTable> {
|
export async function getDataTable(name: string): Promise<DataTable> {
|
||||||
const x = await import(`./${name}`);
|
const allDataTables = (await import('./data/index')).default;
|
||||||
return x.default;
|
return allDataTables[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listDataTables(): Promise<{ name: string }[]> {
|
/* Used in case later we want any kind of computed extra data */
|
||||||
const x: { name: string }[] = [];
|
export function dataTableLookup(table: DataTable, key: string): any {
|
||||||
for (const key in allDataTables) {
|
return table.data[key];
|
||||||
x.push({ name: key });
|
}
|
||||||
}
|
|
||||||
return x;
|
export async function listDataTables(): Promise<{ [name: string]: DataTable }> {
|
||||||
|
const allDataTables = (await import('./data/index')).default;
|
||||||
|
return allDataTables;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { DataTable };
|
export { DataTable };
|
||||||
|
|||||||
@@ -4,16 +4,14 @@ Used for calculator presets
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
export interface DataTable {
|
export interface DataTable {
|
||||||
[key: string]: {
|
title: string;
|
||||||
title: string;
|
/* A JSON schema properties */
|
||||||
/* A JSON schema properties */
|
columns: {
|
||||||
columns: {
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
data: {
|
||||||
|
[key: string]: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
data: {
|
|
||||||
[key: string]: {
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
import ohmslaw from './ohms_law';
|
import ohmslaw from './ohms_law';
|
||||||
|
import voltagedropinwire from './wire_voltage_drop';
|
||||||
|
|
||||||
export default [ohmslaw];
|
export default [ohmslaw, voltagedropinwire];
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import type { GenericCalcType } from './types';
|
||||||
|
const voltagedropinwire: GenericCalcType = {
|
||||||
|
title: 'Round trip voltage drop in cable',
|
||||||
|
name: 'cable-voltage-drop',
|
||||||
|
formula: 'x = (((p * L) / (A/10**6) ) *2) * I**2',
|
||||||
|
selections: [
|
||||||
|
{
|
||||||
|
title: 'Material',
|
||||||
|
source: 'material-electrical-properties',
|
||||||
|
default: 'Copper',
|
||||||
|
bind: {
|
||||||
|
p: 'resistivity_20c'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: 'Wire Gauge',
|
||||||
|
source: 'wire-gauge',
|
||||||
|
default: '24 AWG',
|
||||||
|
bind: {
|
||||||
|
A: 'area'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
variables: [
|
||||||
|
{
|
||||||
|
name: 'L',
|
||||||
|
title: 'Length',
|
||||||
|
unit: 'm',
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'A',
|
||||||
|
title: 'Wire Area',
|
||||||
|
unit: 'mm',
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'I',
|
||||||
|
title: 'Current',
|
||||||
|
unit: 'A',
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'p',
|
||||||
|
title: 'Resistivity',
|
||||||
|
unit: 'Ω/m3',
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'x',
|
||||||
|
title: 'Voltage Drop',
|
||||||
|
unit: 'V'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export default voltagedropinwire;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { UpdateField } from '@components/options/ToolOptions';
|
|||||||
import { InitialValuesType } from './types';
|
import { InitialValuesType } from './types';
|
||||||
import type { GenericCalcType } from './data/types';
|
import type { GenericCalcType } from './data/types';
|
||||||
import type { DataTable } from 'datatables';
|
import type { DataTable } from 'datatables';
|
||||||
import { getDataTable } from 'datatables';
|
import { getDataTable, dataTableLookup } from 'datatables';
|
||||||
|
|
||||||
import nerdamer from 'nerdamer';
|
import nerdamer from 'nerdamer';
|
||||||
import 'nerdamer/Algebra';
|
import 'nerdamer/Algebra';
|
||||||
@@ -77,8 +77,6 @@ export default async function makeTool(
|
|||||||
currentValues: InitialValuesType,
|
currentValues: InitialValuesType,
|
||||||
updateFieldFunc: UpdateField<InitialValuesType>
|
updateFieldFunc: UpdateField<InitialValuesType>
|
||||||
) => {
|
) => {
|
||||||
const newValsBoundToPreset = { ...valsBoundToPreset };
|
|
||||||
|
|
||||||
const newPresets = { ...currentValues.presets };
|
const newPresets = { ...currentValues.presets };
|
||||||
newPresets[selection] = preset;
|
newPresets[selection] = preset;
|
||||||
updateFieldFunc('presets', newPresets);
|
updateFieldFunc('presets', newPresets);
|
||||||
@@ -86,7 +84,7 @@ export default async function makeTool(
|
|||||||
// Clear old selection
|
// Clear old selection
|
||||||
for (const key in valsBoundToPreset) {
|
for (const key in valsBoundToPreset) {
|
||||||
if (valsBoundToPreset[key] === selection) {
|
if (valsBoundToPreset[key] === selection) {
|
||||||
delete newValsBoundToPreset[key];
|
delete valsBoundToPreset[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,13 +92,19 @@ export default async function makeTool(
|
|||||||
(sel) => sel.title === selection
|
(sel) => sel.title === selection
|
||||||
);
|
);
|
||||||
|
|
||||||
if (preset != '<custom>') {
|
if (preset && preset != '<custom>') {
|
||||||
if (selectionData) {
|
if (selectionData) {
|
||||||
for (const key in selectionData.bind) {
|
for (const key in selectionData.bind) {
|
||||||
newValsBoundToPreset[key] = selection;
|
valsBoundToPreset[key] = selection;
|
||||||
|
|
||||||
|
if (currentValues.outputVariable === key) {
|
||||||
|
handleSelectedTargetChange('', updateFieldFunc);
|
||||||
|
}
|
||||||
|
|
||||||
updateVarField(
|
updateVarField(
|
||||||
key,
|
key,
|
||||||
dataTables[selectionData.source].data[preset][
|
|
||||||
|
dataTableLookup(dataTables[selectionData.source], preset)[
|
||||||
selectionData.bind[key]
|
selectionData.bind[key]
|
||||||
],
|
],
|
||||||
currentValues,
|
currentValues,
|
||||||
@@ -108,14 +112,11 @@ export default async function makeTool(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setValsBoundToPreset(newValsBoundToPreset);
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Preset "${preset}" is not valid for selection "${selection}"`
|
`Preset "${preset}" is not valid for selection "${selection}"`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setValsBoundToPreset(newValsBoundToPreset);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
calcData.variables.forEach((variable) => {
|
calcData.variables.forEach((variable) => {
|
||||||
@@ -138,13 +139,16 @@ export default async function makeTool(
|
|||||||
if (selection.default == '<custom>') return;
|
if (selection.default == '<custom>') return;
|
||||||
for (const key in selection.bind) {
|
for (const key in selection.bind) {
|
||||||
initialValues.vars[key] = {
|
initialValues.vars[key] = {
|
||||||
value:
|
value: dataTableLookup(
|
||||||
dataTables[selection.source].data[selection.default][
|
dataTables[selection.source],
|
||||||
selection.bind[key]
|
selection.default
|
||||||
],
|
)[selection.bind[key]],
|
||||||
unit: dataTables[selection.source].cols[selection.bind[key]].unit
|
|
||||||
|
unit:
|
||||||
|
dataTables[selection.source].columns[selection.bind[key]]?.unit ||
|
||||||
|
''
|
||||||
};
|
};
|
||||||
valsBoundToPreset[key] = selection.default;
|
valsBoundToPreset[key] = selection.title;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -182,9 +186,12 @@ export default async function makeTool(
|
|||||||
disablePortal
|
disablePortal
|
||||||
id="combo-box-demo"
|
id="combo-box-demo"
|
||||||
value={values.presets[preset.title]}
|
value={values.presets[preset.title]}
|
||||||
options={Object.keys(
|
options={[
|
||||||
dataTables[preset.source].data
|
'<custom>',
|
||||||
).sort()}
|
...Object.keys(
|
||||||
|
dataTables[preset.source].data
|
||||||
|
).sort()
|
||||||
|
]}
|
||||||
sx={{ width: 300 }}
|
sx={{ width: 300 }}
|
||||||
onChange={(event, newValue) => {
|
onChange={(event, newValue) => {
|
||||||
handleSelectedPresetChange(
|
handleSelectedPresetChange(
|
||||||
@@ -207,7 +214,7 @@ export default async function makeTool(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Input Variables',
|
title: 'Variables',
|
||||||
component: (
|
component: (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
@@ -221,7 +228,7 @@ export default async function makeTool(
|
|||||||
<TableBody>
|
<TableBody>
|
||||||
{calcData.variables.map((variable) => (
|
{calcData.variables.map((variable) => (
|
||||||
<TableRow key={variable.name}>
|
<TableRow key={variable.name}>
|
||||||
<TableCell>{variable.name}</TableCell>
|
<TableCell>{variable.title}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<TextFieldWithDesc
|
<TextFieldWithDesc
|
||||||
title={variable.title}
|
title={variable.title}
|
||||||
@@ -253,6 +260,9 @@ export default async function makeTool(
|
|||||||
<Radio
|
<Radio
|
||||||
value={variable.name}
|
value={variable.name}
|
||||||
checked={values.outputVariable === variable.name}
|
checked={values.outputVariable === variable.name}
|
||||||
|
disabled={
|
||||||
|
valsBoundToPreset[variable.name] !== undefined
|
||||||
|
}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleSelectedTargetChange(
|
handleSelectedTargetChange(
|
||||||
variable.name,
|
variable.name,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ allGenericCalcs.forEach((x) => {
|
|||||||
tools.push(
|
tools.push(
|
||||||
defineTool('number', {
|
defineTool('number', {
|
||||||
name: x.title,
|
name: x.title,
|
||||||
path: 'generic-calc/x.name',
|
path: 'generic-calc/' + x.name,
|
||||||
icon: '',
|
icon: '',
|
||||||
description: '',
|
description: '',
|
||||||
shortDescription: '',
|
shortDescription: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user