Skip to content

Commit

Permalink
Fix: WireMaterials function call
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRasho committed Nov 7, 2023
1 parent db427cc commit 7b70ff3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/organisms/simulationDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { onMounted } from 'vue'
import { AnimationEngine } from '../../lib/AnimationEngine'
let engine;
let engine
onMounted(() => {
engine = new AnimationEngine(document.getElementById('simulationContainer'))
Expand Down
55 changes: 38 additions & 17 deletions src/lib/WireMaterials.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 7b70ff3

Please sign in to comment.