Bugzilla – Bug 2309
AcousticModemEnergyModel::ChangeState
Last modified: 2016-03-11 20:46:02 UTC
The calculation of the energy to decrease is wrong energyToDecrease = duration.GetSeconds () * m_txPowerW * supplyVoltage; energyToDecrease = duration.GetSeconds () * m_rxPowerW * supplyVoltage; energyToDecrease = duration.GetSeconds () * m_idlePowerW * supplyVoltage; energyToDecrease = duration.GetSeconds () * m_sleepPowerW * supplyVoltage; Should be changed to energyToDecrease = duration.GetSeconds () * m_txPowerW; energyToDecrease = duration.GetSeconds () * m_rxPowerW; energyToDecrease = duration.GetSeconds () * m_idlePowerW; energyToDecrease = duration.GetSeconds () * m_sleepPowerW;
Indeed, Amps = Watts * Seconds, the Volts is already included. If we want to have a voltage-dependent model, we'd need to specify the current drawn by the modem in each state in Amperes, just like the Wi-Fi model does.
Please have a look at the below code. void AcousticModemEnergyModel::ChangeState (int newState) { NS_LOG_FUNCTION (this << newState); // NS_ASSERT (IsStateTransitionValid ((MicroModemState) newState)); Time duration = Simulator::Now () - m_lastUpdateTime; NS_ASSERT (duration.GetNanoSeconds () >= 0); // check if duration is valid // energy to decrease = current * voltage * time double energyToDecrease = 0.0; double supplyVoltage = m_source->GetSupplyVoltage (); switch (m_currentState) { case UanPhy::TX: energyToDecrease = duration.GetSeconds () * m_txPowerW; m_txCurrentA = m_txPowerW / supplyVoltage; break; case UanPhy::RX: energyToDecrease = duration.GetSeconds () * m_rxPowerW; m_rxCurrentA = m_rxPowerW / supplyVoltage; break; case UanPhy::IDLE: energyToDecrease = duration.GetSeconds () * m_idlePowerW; m_idleCurrentA = m_idlePowerW / supplyVoltage; break; case UanPhy::SLEEP: energyToDecrease = duration.GetSeconds () * m_sleepPowerW; m_sleepCurrentA = m_sleepPowerW / supplyVoltage; break; default: NS_FATAL_ERROR ("AcousticModemEnergyModel:Undefined radio state!"); } // update total energy consumption m_totalEnergyConsumption += energyToDecrease; // update last update time stamp m_lastUpdateTime = Simulator::Now (); // notify energy source m_source->UpdateEnergySource (); // update current state & last update time stamp SetMicroModemState (newState); // some debug message NS_LOG_DEBUG ("AcousticModemEnergyModel:Total energy consumption at node #" << m_node->GetId () << " is " << m_totalEnergyConsumption << "J"); } double AcousticModemEnergyModel::DoGetCurrentA (void) const { NS_LOG_FUNCTION (this); switch (m_currentState) { case UanPhy::TX: return m_txCurrentA; case UanPhy::RX: return m_rxCurrentA; case UanPhy::IDLE: return m_idleCurrentA; case UanPhy::SLEEP: return m_sleepCurrentA; default: NS_FATAL_ERROR ("AcousticModemEnergyModel:Undefined radio state!"); } }
This is a duplicate of Bug 1631 https://www.nsnam.org/bugzilla/0. My suggestion is to remove the multiplication by supplyVoltage as suggested both here and in 1631. Andrea, do you agree on this?
*** This bug has been marked as a duplicate of bug 1631 ***