From 7b70ff3b2c83581180494fafad7a783c0446bf2c Mon Sep 17 00:00:00 2001 From: DanielRasho Date: Mon, 6 Nov 2023 20:56:37 -0600 Subject: [PATCH] Fix: WireMaterials function call --- .../organisms/simulationDisplay.vue | 2 +- src/lib/WireMaterials.js | 55 +++++++++++++------ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/components/organisms/simulationDisplay.vue b/src/components/organisms/simulationDisplay.vue index fd6e2f2..ea8af76 100644 --- a/src/components/organisms/simulationDisplay.vue +++ b/src/components/organisms/simulationDisplay.vue @@ -6,7 +6,7 @@ import { onMounted } from 'vue' import { AnimationEngine } from '../../lib/AnimationEngine' -let engine; +let engine onMounted(() => { engine = new AnimationEngine(document.getElementById('simulationContainer')) diff --git a/src/lib/WireMaterials.js b/src/lib/WireMaterials.js index f0c7b33..5e8265b 100644 --- a/src/lib/WireMaterials.js +++ b/src/lib/WireMaterials.js @@ -21,7 +21,19 @@ export const diameterUnits = Object.freeze({ AWG: 'AWG' }) -const AVOGADRO = 6.02214076e23 +const AVOGADRO = 6.02214076e23 + +/** + * Calcula la densidad de carga del elemento. + * + * Las dimensionales de la densidad son: electrones / m^3. + * @param {Number} electrons La cantidad de electrones que tiene un átomo del elemento + * @param {Number} molarMass La cantidad de gramos que tiene un mol del elemento + * @param {Number} density La cantidad de gramos que tiene un cm^3 del elemento + * @returns {Number} La densidad de carga en electrones/m^3. + */ +const computeChargeDensity = (electrons, molarMass, density) => + ((electrons * AVOGADRO) / molarMass) * density * 100_00_00 /** * Enum of posible wire materials along with its @@ -30,38 +42,47 @@ const AVOGADRO = 6.02214076e23 export const WIRE_MATERIALS = Object.freeze({ GOLD: new WireMaterial( 'Gold', - new SimulationMagnitude(computeChargeDensity(79, 196.96657, 19.3), 'Charge Density', '1/m³'), + new SimulationMagnitude( + computeChargeDensity(79, 196.96657, 19.3), + 'Charge Density', + '1/m³' + ), new SimulationMagnitude(2, 'Resistivity', 'ohm·m') ), SILVER: new WireMaterial( 'Silver', - new SimulationMagnitude(computeChargeDensity(47, 107.8682, 10.49), 'Charge Density', '1/m³'), + new SimulationMagnitude( + computeChargeDensity(47, 107.8682, 10.49), + 'Charge Density', + '1/m³' + ), new SimulationMagnitude(2, 'Resistivity', 'ohm·m') ), COPPER: new WireMaterial( 'Copper', - new SimulationMagnitude(computeChargeDensity(29, 63.546, 8.96), 'Charge Density', '1/m³'), + new SimulationMagnitude( + computeChargeDensity(29, 63.546, 8.96), + 'Charge Density', + '1/m³' + ), new SimulationMagnitude(2, 'Resistivity', 'ohm·m') ), ALUMINUM: new WireMaterial( 'Aluminum', - new SimulationMagnitude(computeChargeDensity(13, 26.982, 2.7), 'Charge Density', '1/m³'), + new SimulationMagnitude( + computeChargeDensity(13, 26.982, 2.7), + 'Charge Density', + '1/m³' + ), new SimulationMagnitude(2, 'Resistivity', 'ohm·m') ), GRAPHITE: new WireMaterial( 'Graphite', - new SimulationMagnitude(computeChargeDensity(4, 12.0107, 2.26), 'Charge Density', '1/m³'), + new SimulationMagnitude( + computeChargeDensity(4, 12.0107, 2.26), + 'Charge Density', + '1/m³' + ), new SimulationMagnitude(2, 'Resistivity', 'ohm·m') ) }) - -/** - * Calcula la densidad de carga del elemento. - * - * Las dimensionales de la densidad son: electrones / m^3. - * @param {Number} electrons La cantidad de electrones que tiene un átomo del elemento - * @param {Number} molarMass La cantidad de gramos que tiene un mol del elemento - * @param {Number} density La cantidad de gramos que tiene un cm^3 del elemento - * @returns {Number} La densidad de carga en electrones/m^3. - */ -const computeChargeDensity = (electrons, molarMass, density) => electrons * AVOGADRO / molarMass * density * 100_00_00 \ No newline at end of file