00001 // LogChemical.cpp: implementation of the CLogChemical class. 00002 // 00004 00005 #include "LogChemical.h" 00006 00008 // Construction/Destruction 00010 00011 CLogChemical::CLogChemical(int chemicalNumber, std::string name, std::vector<Chemical *> chemRefVector) 00012 :CAlgebraicChemical(chemicalNumber,name,chemRefVector) 00013 { 00014 00015 } 00016 00017 CLogChemical::~CLogChemical() 00018 { 00019 00020 } 00021 00022 void CLogChemical::ComputeAmount() 00023 { 00024 double temp = 0.0; 00025 for(int i = 0; i < m_vpChemRefVector.size(); i++) 00026 { 00027 temp += m_vpChemRefVector[i]->GetAmount(); 00028 } 00029 amount = log(temp); 00030 } 00031 00032 void CLogChemical::ComputeInitialAmount() 00033 { 00034 double temp = 0.0; 00035 for(int i = 0; i < m_vpChemRefVector.size(); i++) 00036 { 00037 temp += m_vpChemRefVector[i]->GetInitialAmount(); 00038 } 00039 initialAmount = log(temp); 00040 } 00041 00042 void CLogChemical::ComputeErrorInInitialAmount() 00043 { 00044 double temp = 0.0; 00045 double error; 00046 double valuesum = 0.0; 00047 for(int i = 0; i < m_vpChemRefVector.size(); i++) 00048 { 00049 error = m_vpChemRefVector[i]->GetErrorInInitialAmount(); 00050 valuesum += m_vpChemRefVector[i]->GetInitialAmount(); 00051 temp += error*error; 00052 } 00053 errorInInitialAmount = sqrt(temp)/valuesum; 00054 }