diff options
author | 2024-03-07 01:39:41 +0600 | |
---|---|---|
committer | 2024-03-07 01:39:41 +0600 | |
commit | a8aa863d7e9732dc65f86bb3f4cbdd243e6ad6da (patch) | |
tree | d88c34054e8005358f98f4c81d1574ebeb39dd07 /headers | |
download | entropy-calc-a8aa863d7e9732dc65f86bb3f4cbdd243e6ad6da.tar.gz entropy-calc-a8aa863d7e9732dc65f86bb3f4cbdd243e6ad6da.zip |
Add water element and entropy calculator project files
Diffstat (limited to 'headers')
-rw-r--r-- | headers/allElements.cpp | 11 | ||||
-rw-r--r-- | headers/allElements.h | 12 | ||||
-rw-r--r-- | headers/genericElement.h | 79 |
3 files changed, 102 insertions, 0 deletions
diff --git a/headers/allElements.cpp b/headers/allElements.cpp new file mode 100644 index 0000000..435f680 --- /dev/null +++ b/headers/allElements.cpp @@ -0,0 +1,11 @@ +#include<vector> +#include "../elements/water.h" +#include "genericElement.h" + + +vector<genericElement*> getAllElements() +{ + vector<genericElement*> elements; + elements.push_back(new water()); + return elements; +} diff --git a/headers/allElements.h b/headers/allElements.h new file mode 100644 index 0000000..5bf3627 --- /dev/null +++ b/headers/allElements.h @@ -0,0 +1,12 @@ +// get all elements from elements folder + +#pragma once +#ifndef ALL_ELEMENTS +#define ALL_ELEMENTS + +#include<vector> +#include "genericElement.h" + +std::vector<genericElement*> getAllElements(); + +#endif diff --git a/headers/genericElement.h b/headers/genericElement.h new file mode 100644 index 0000000..5e7044d --- /dev/null +++ b/headers/genericElement.h @@ -0,0 +1,79 @@ +#ifndef GENERICELEMENT_H_INCLUDED +#define GENERICELEMENT_H_INCLUDED + + +#include <iostream> +using namespace std; + +class genericElement +{ +private: + string elementName; + double latentHeatOfFusion; + double latentHeatOfVaporization; + double specificHeatSolid; + double specificHeatLiquid; + double specificHeatGas; + double meltingPoint; + double boilingPoint; + +protected: + void setElementName(string value) { elementName = value; } + void setLatentHeatOfFusion(double value) { latentHeatOfFusion = value; } + void setLatentHeatOfVaporization(double value) { latentHeatOfVaporization = value; } + void setSpecificHeatSolid(double value) { specificHeatSolid = value; } + void setSpecificHeatLiquid(double value) { specificHeatLiquid = value; } + void setSpecificHeatGas(double value) { specificHeatGas = value; } + void setMeltingPoint(double value) { meltingPoint = value; } + void setBoilingPoint(double value) { boilingPoint = value; } + +public: + string getElementName() { return elementName; } + double getLatentHeatOfFusion() { return latentHeatOfFusion; } + double getLatentHeatOfVaporization() { return latentHeatOfVaporization; } + double getSpecificHeatSolid() { return specificHeatSolid; } + double getSpecificHeatLiquid() { return specificHeatLiquid; } + double getSpecificHeatGas() { return specificHeatGas; } + double getMeltingPoint() { return meltingPoint; } + double getBoilingPoint() { return boilingPoint; } + + double totalEntropyChange(double mass, double fromTemp, double toTemp) + { + double totalEntropy = 0; + if (fromTemp <= meltingPoint && toTemp <= meltingPoint) + { + totalEntropy = mass * specificHeatSolid * (toTemp - fromTemp); + } + else if (fromTemp <= meltingPoint && toTemp >= meltingPoint && toTemp <= boilingPoint) + { + totalEntropy = mass * specificHeatSolid * (meltingPoint - fromTemp); + totalEntropy += mass * latentHeatOfFusion / meltingPoint; + totalEntropy += mass * specificHeatLiquid * (toTemp - meltingPoint); + } + else if (fromTemp <= meltingPoint && toTemp >= boilingPoint) + { + totalEntropy = mass * specificHeatSolid * (meltingPoint - fromTemp); + totalEntropy += mass * latentHeatOfFusion; + totalEntropy += mass * specificHeatLiquid * (boilingPoint - meltingPoint); + totalEntropy += mass * latentHeatOfVaporization; + totalEntropy += mass * specificHeatGas * (toTemp - boilingPoint); + } + else if (fromTemp >= meltingPoint && fromTemp <= boilingPoint && toTemp >= meltingPoint && toTemp <= boilingPoint) + { + totalEntropy = mass * specificHeatLiquid * (toTemp - fromTemp); + } + else if (fromTemp >= meltingPoint && fromTemp <= boilingPoint && toTemp >= boilingPoint) + { + totalEntropy = mass * specificHeatLiquid * (boilingPoint - fromTemp); + totalEntropy += mass * latentHeatOfVaporization; + totalEntropy += mass * specificHeatGas * (toTemp - boilingPoint); + } + else if (fromTemp >= boilingPoint && toTemp >= boilingPoint) + { + totalEntropy = mass * specificHeatGas * (toTemp - fromTemp); + } + return totalEntropy; + } +}; + +#endif // GENERICELEMENT_H_INCLUDED |