00001 #include "MTDataComp.h"
00002
00003
00004
00005 #include <cmath>
00006 #include <algorithm>
00007
00008 MTDataComp::MTDataComp(const int nfreq):
00009 name("unknown"),
00010 rhoa(nfreq),
00011 phi(nfreq),
00012 drhoa(nfreq),
00013 dphi(nfreq),
00014 Z(nfreq),
00015 dZ(nfreq)
00016 {
00017
00018 }
00019
00020 MTDataComp::~MTDataComp()
00021 {
00022 }
00023
00024 void MTDataComp::Assign(const int nfreq)
00025 {
00026 rhoa.assign(nfreq,0);
00027 phi.assign(nfreq,0);
00028 drhoa.assign(nfreq,0);
00029 dphi.assign(nfreq,0);
00030 Z.assign(nfreq,0);
00031 dZ.assign(nfreq,0);
00032 }
00033
00034 MTDataComp& MTDataComp::operator= (const MTDataComp& source)
00035 {
00036 this->rhoa.assign(source.Z.size(),0);
00037 this->phi.assign(source.Z.size(),0);
00038 this->dphi.assign(source.Z.size(),0);
00039 this->drhoa.assign(source.Z.size(),0);
00040 this->Z.assign(source.Z.size(),0);
00041 this->dZ.assign(source.Z.size(),0);
00042 this->name = source.name;
00043 copy(source.rhoa.begin(),source.rhoa.end(),this->rhoa.begin());
00044 copy(source.phi.begin(),source.phi.end(),this->phi.begin());
00045 copy(source.drhoa.begin(),source.drhoa.end(),this->drhoa.begin());
00046 copy(source.dphi.begin(),source.dphi.end(),this->dphi.begin());
00047 copy(source.Z.begin(),source.Z.end(),this->Z.begin());
00048 copy(source.dZ.begin(),source.dZ.end(),this->dZ.begin());
00049 return *this;
00050 }
00051
00052
00053
00054
00055
00056 void MTDataComp::Update(trealdata frequency)
00057 {
00058
00059 if (rhoa.empty())
00060 {
00061
00062 rhoa.assign(frequency.size(),0);
00063 phi.assign(frequency.size(),0);
00064 drhoa.assign(frequency.size(),0);
00065 dphi.assign(frequency.size(),0);
00066 }
00067
00068 for (unsigned int k = 0; k < frequency.size(); ++k)
00069 {
00070 rhoa.at(k) = 1./(2 * PI * frequency.at(k)) * mu * (pow(Z.at(k).real(),2)+pow(Z.at(k).imag(),2)) * pow(1000.0,2);
00071 phi.at(k) = atan(Z.at(k).imag()/Z.at(k).real())/ PI *180;
00072 drhoa.at(k) = 1./(PI * frequency.at(k)) * mu * abs(Z.at(k)) * dZ.at(k)* pow(1000.0,2);
00073 dphi.at(k) = dZ.at(k) * abs(Z.at(k)) * 1./(1.+ pow(Z.at(k).imag()/Z.at(k).real(),2)) * 1./pow(Z.at(k).real(),2)/ PI *180;
00074 }
00075 }
00076
00077
00078 void MTDataComp::erase(const int index)
00079 {
00080 rhoa.erase(rhoa.begin()+index);
00081 phi.erase(phi.begin()+index);
00082 drhoa.erase(drhoa.begin()+index);
00083 dphi.erase(dphi.begin()+index);
00084 Z.erase(Z.begin()+index);
00085 dZ.erase(dZ.begin()+index);
00086 }
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099