Did algorithm for calculations
This commit is contained in:
Binary file not shown.
@@ -3,3 +3,81 @@
|
||||
451 492 1697839689424050960 Empirical c1f8fa8d06d83ff6
|
||||
0 428 1697839711124124526 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
429 472 1697839711167458006 Empirical c1f8fa8d06d83ff6
|
||||
1 512 1697868817813949732 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
512 552 1697868817850616526 Empirical c1f8fa8d06d83ff6
|
||||
0 606 1697868929414330798 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
607 652 1697868929457664278 Empirical c1f8fa8d06d83ff6
|
||||
0 594 1697869239772057297 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
594 637 1697869239812057435 Empirical c1f8fa8d06d83ff6
|
||||
1 594 1697869282782204194 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
594 638 1697869282825537676 Empirical c1f8fa8d06d83ff6
|
||||
0 624 1697870231708777699 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
624 666 1697870231752111180 Empirical c1f8fa8d06d83ff6
|
||||
1 647 1697870319462410709 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
647 691 1697870319505744190 Empirical c1f8fa8d06d83ff6
|
||||
1 635 1697870360735885027 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
635 679 1697870360779218508 Empirical c1f8fa8d06d83ff6
|
||||
0 624 1697870378315945049 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
624 666 1697870378359278530 Empirical c1f8fa8d06d83ff6
|
||||
0 735 1697954486515504530 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
736 784 1697954486565502505 Empirical c1f8fa8d06d83ff6
|
||||
0 617 1697954536629829601 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
617 660 1697954536673160676 Empirical c1f8fa8d06d83ff6
|
||||
0 619 1697954553068947953 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
619 666 1697954553115612047 Empirical c1f8fa8d06d83ff6
|
||||
1 633 1697954587793611065 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
633 679 1697954587840274928 Empirical c1f8fa8d06d83ff6
|
||||
1 617 1697954599529563869 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
617 661 1697954599572894537 Empirical c1f8fa8d06d83ff6
|
||||
1 614 1697954760745286354 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
614 659 1697954760788616566 Empirical c1f8fa8d06d83ff6
|
||||
0 620 1697954787583340940 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
620 661 1697954787623338025 Empirical c1f8fa8d06d83ff6
|
||||
0 647 1697956180000956779 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
647 690 1697956180044286810 Empirical c1f8fa8d06d83ff6
|
||||
0 640 1697956290232553599 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
640 684 1697956290275883629 Empirical c1f8fa8d06d83ff6
|
||||
0 639 1697956530920872082 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
639 693 1697956530970868270 Empirical c1f8fa8d06d83ff6
|
||||
0 638 1697956712300378471 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
638 682 1697956712343708501 Empirical c1f8fa8d06d83ff6
|
||||
1 619 1697956742981372929 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
619 661 1697956743021369880 Empirical c1f8fa8d06d83ff6
|
||||
0 606 1697956792420937374 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
606 648 1697956792460934325 Empirical c1f8fa8d06d83ff6
|
||||
0 637 1697956800903624057 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
638 683 1697956800946954088 Empirical c1f8fa8d06d83ff6
|
||||
1 642 1697956920411180411 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
642 686 1697956920454510440 Empirical c1f8fa8d06d83ff6
|
||||
1 624 1697956965304424774 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
625 668 1697956965347754805 Empirical c1f8fa8d06d83ff6
|
||||
0 614 1697956970644017727 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
614 656 1697956970687347757 Empirical c1f8fa8d06d83ff6
|
||||
1 718 1698022522769957600 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
718 775 1698022522826624266 Empirical c1f8fa8d06d83ff6
|
||||
1 626 1698023149533274256 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
627 671 1698023149576607589 Empirical c1f8fa8d06d83ff6
|
||||
1 617 1698023190349939833 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
617 661 1698023190393273166 Empirical c1f8fa8d06d83ff6
|
||||
1 640 1698023212706605908 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
640 683 1698023212749939241 Empirical c1f8fa8d06d83ff6
|
||||
0 627 1698023297536603635 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
627 672 1698023297579936967 Empirical c1f8fa8d06d83ff6
|
||||
1 663 1698023401276600865 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
663 710 1698023401323267530 Empirical c1f8fa8d06d83ff6
|
||||
1 647 1698023413749933862 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
647 691 1698023413793267195 Empirical c1f8fa8d06d83ff6
|
||||
0 606 1698023578626596113 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
606 651 1698023578673262780 Empirical c1f8fa8d06d83ff6
|
||||
1 620 1698023694233259696 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
620 662 1698023694276593026 Empirical c1f8fa8d06d83ff6
|
||||
0 612 1698023745879924992 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
612 658 1698023745923258324 Empirical c1f8fa8d06d83ff6
|
||||
1 607 1698023794246590385 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
607 653 1698023794293257050 Empirical c1f8fa8d06d83ff6
|
||||
1 636 1698024140373247786 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
636 682 1698024140419914451 Empirical c1f8fa8d06d83ff6
|
||||
1 629 1698024150253247524 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
629 672 1698024150296580856 Empirical c1f8fa8d06d83ff6
|
||||
1 629 1698024208229912643 CMakeFiles/Empirical.dir/main.cpp.o a35f251f265f22e1
|
||||
629 672 1698024208273245973 Empirical c1f8fa8d06d83ff6
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,3 @@
|
||||
Start testing: Oct 20 17:08 CDT
|
||||
Start testing: Oct 22 20:23 CDT
|
||||
----------------------------------------------------------
|
||||
End testing: Oct 20 17:08 CDT
|
||||
End testing: Oct 22 20:23 CDT
|
||||
|
||||
73
main.cpp
73
main.cpp
@@ -1,5 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
|
||||
class Element {
|
||||
@@ -11,7 +13,7 @@ public:
|
||||
}
|
||||
|
||||
//Return a string representation of empirical formula
|
||||
static string find_empirical(const string& compound);
|
||||
static string find_empirical(map<string, double> elms);
|
||||
|
||||
|
||||
};
|
||||
@@ -137,16 +139,79 @@ const map<string, double> Element::weights = {
|
||||
{"Og", 294}
|
||||
};
|
||||
|
||||
class Empirical {
|
||||
string Element::find_empirical(map<string, double> elms) {
|
||||
//Map will hold the elements with their values in moles
|
||||
map<string, double> moles;
|
||||
|
||||
map<string, double>::iterator it;
|
||||
double lowest = 9999999;
|
||||
for(it = elms.begin(); it != elms.end(); it++) {
|
||||
double mole = it->second / getWeight(it->first);
|
||||
if(mole < lowest)
|
||||
lowest = mole;
|
||||
|
||||
|
||||
//cout << "Element " << it->first << " has this many moles: " << ceil(mole * 100) / 100 << endl;
|
||||
moles.insert(make_pair(it->first, mole));
|
||||
}
|
||||
|
||||
for(it = moles.begin(); it != moles.end(); it++) {
|
||||
it->second /= lowest;
|
||||
cout << "Element " << it->first << " has this many moles: " << ceil(it->second * 100) / 100 << endl;
|
||||
}
|
||||
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
double integer_maker(const vector<double>& coefs) {
|
||||
cout << "Started Integer Maker" << endl;
|
||||
int i = 1;
|
||||
bool isGood = false;
|
||||
for(auto &x : coefs) {
|
||||
cout << "Initial check if ints" << endl;
|
||||
double intpart = 0.0;
|
||||
if(modf(x, &intpart) != 0.0) {
|
||||
isGood = false;
|
||||
break;
|
||||
}
|
||||
isGood = true;
|
||||
}
|
||||
|
||||
|
||||
if(!isGood) {
|
||||
cout << "So they're not ints. Starting algorithm to intinize them" << endl;
|
||||
for (i = 2; (i < 9999999) && !isGood; i++) {
|
||||
cout << "Outer loop for i=" << i << endl;
|
||||
for (auto x: coefs) {
|
||||
cout << "Running thru coefs for coef: " << x << endl;
|
||||
double y = x;
|
||||
double intpart;
|
||||
//cout << "y * i: " << y << " " << i << " " << " = " << y*i << endl;
|
||||
double d_val = ceil(modf(y * i, &intpart) * 10) / 10;
|
||||
cout << "d_val: " << d_val <<endl;
|
||||
if((d_val != 0.0) && (d_val+0.1 != 0.0) && (d_val-0.1 != 0.0) &&
|
||||
(d_val != 1) && (d_val+0.1 != 1) && (d_val-0.1 != 1)) {
|
||||
isGood = false;
|
||||
break;
|
||||
}
|
||||
isGood = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return i-1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main() {
|
||||
cout << "C: " << Element::getWeight("Sb");
|
||||
map<string, double> elms = { {"C", 49.3}, {"H", 6.9}, {"O", 43.8} };
|
||||
//Element::find_empirical(elms);
|
||||
|
||||
vector<double> nums = {1, 2.33};
|
||||
|
||||
cout << integer_maker(nums) << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user