-
Notifications
You must be signed in to change notification settings - Fork 0
/
Thermodynamics.lua
45 lines (39 loc) · 1.23 KB
/
Thermodynamics.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local Thermodynamics = {}
setmetatable(Thermodynamics, {__index = Thermodynamics})
-- q = mCΔT
--- @param mass number
--- @param heatCapacity number
--- @param tempChanges number
--- @return number heatEnergy J
function Thermodynamics:heatEnergy(mass, heatCapacity, tempChanges)
local heatEnergy = mass * heatCapacity * tempChanges
return heatEnergy
end
-- C = q/(mΔT)
---@param heatEnergy number
---@param mass number
---@param tempChanges number
---@return number heatCapacity J/kg.K
function Thermodynamics:heatCapacity(heatEnergy, mass, tempChanges)
local heatCapacity = heatEnergy / (mass * tempChanges)
return heatCapacity
end
-- ΔT = q/(mC)
---@param heatEnergy number
---@param mass number
---@param heatCapacity number
---@return number tempChanges K
function Thermodynamics:temperatureChanges(heatEnergy, mass, heatCapacity)
local tempChanges = heatEnergy / (mass * heatCapacity)
return tempChanges
end
-- m = q / (cΔT)
---@param heatEnergy number
---@param heatCapacity number
---@param tempChanges number
---@return number heatMass kg
function Thermodynamics:heatMass(heatEnergy, heatCapacity, tempChanges)
local heatMass = heatEnergy / (heatCapacity * tempChanges)
return heatMass
end
return Thermodynamics