Commit 4d29d005 authored by Oliver Bock's avatar Oliver Bock
Browse files

Optimized Omega0 handling (still just a workaround)

parent b2c812c9
......@@ -66,9 +66,10 @@ void Fidelity::Engine::TimeDomainEngine::init()
const long iterations = (long)ceil(duration*frequency);
const double timeStepLength = 1.0 / frequency;
const double speedOfLight = m_SimulationSetup->SpeedOfLight()->Value();
const double defaultWavelength = m_SimulationSetup->DefaultWavelength()->Value();
//TODO: omega0 needs to be a global parameter (maybe just instead of "defaultWavelength"). All components have to use "(local_omega - omega0)" instead of the plain "omega0" for correct results. "local_omega" (not omega0) is usually derived from the field being passed to a component (e.g. a field having sidebands). Therefore it's likely that we need to extend the current field description to a (literally) complex object which also contains information about sidebands etc. For the time being we just set "omega0" to a fixed value of "0" until our field description provides for more complex information.
const double omega0 = 0;
//TODO: omega0 needs to be a global parameter (maybe just instead of "defaultWavelength"). All components have to use "(offsetOmega0 - omega0)" instead of the plain "omega0" for correct results. "offsetOmega0" is usually derived from the field being passed to a component (e.g. a field having sidebands). Therefore it's likely that we need to extend the current field description to a (literally) complex object which also contains information about sidebands etc. For the time being we just set "omega0" to a fixed value of "defaultWavelength" until our field description provides for more complex information.
const double omega0 = defaultWavelength;
// Auto-adjust the notification interval to a reasonable amount
m_StepSignalInterval = iterations / 500;
......
......@@ -118,6 +118,14 @@ void Fidelity::Plugin::Component::Space::init(const long& timeStepAmount, const
m_Omega0 = defaultFrequency;
m_SpeedOfLight = speedOfLight;
// adjust length to ensure resonance condition (subtract remainder)
double lengthCorrection = std::fmod(m_Length->Value() * m_Refraction->Value(), defaultFrequency);
// TODO: take numerical errors into account (correction != 0 even if n*lambda)
if(lengthCorrection > 0) {
m_Length->setValue(m_Length->Value() - lengthCorrection);
qDebug() << "Corrected length of " << m_Label << " by -" << lengthCorrection << "m to ensure resonance condition...";
}
// set up FIFO queues (bidirectional) for the discretised "parts" of space
const complex<double> queueInitValue(0.0,0.0);
const unsigned int queueSize = (int)ceil(m_Length->Value() / speedOfLight / m_Refraction->Value() / timeStepLength);
......@@ -141,8 +149,8 @@ void Fidelity::Plugin::Component::Space::step(const long& iteration, const doubl
Q_UNUSED(iteration)
Q_UNUSED(t)
//TODO: the following should read "(m_Omega - m_Omega0)" instead of just "m_Omega0". Have a look at TimeDomainEngine::init() for more info on this!
const double phi = m_Omega0 * m_Length->Value() * m_Refraction->Value() / m_SpeedOfLight;
//TODO: the following should read "offsetOmega0 - m_Omega0" instead of just "m_Omega0 - m_Omega0" (fixed 0). Have a look at TimeDomainEngine::init() for more info on this!
const double phi = (m_Omega0 - m_Omega0) * m_Length->Value() * m_Refraction->Value() / m_SpeedOfLight;
m_BeamNode1->setOutputField(m_ScalarFieldQueueBeamNode2->takeFirst() * exp(complex<double>(0.0,phi)));
m_BeamNode2->setOutputField(m_ScalarFieldQueueBeamNode1->takeFirst() * exp(complex<double>(0.0,phi)));
......
......@@ -21,6 +21,8 @@
#ifndef SPACE_H
#define SPACE_H
#include <cmath>
#include <QList>
#include "AComponent.h"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment