aboutsummaryrefslogtreecommitdiff
path: root/src/devices
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/pcm_device.cpp21
-rw-r--r--src/devices/pcm_device.h33
2 files changed, 33 insertions, 21 deletions
diff --git a/src/devices/pcm_device.cpp b/src/devices/pcm_device.cpp
index dc018da..f99b0f3 100644
--- a/src/devices/pcm_device.cpp
+++ b/src/devices/pcm_device.cpp
@@ -12,12 +12,14 @@ void PCMElement::on_input_changed()
// setting the transmission for the initial state
update_transmission_local();
-
if (specsGlobalConfig.verbose_component_initialization)
{
cout << name() << ":" << endl;
cout << "Emelt = " << m_meltEnergy*1e9 << " nJ" << endl;
cout << "Nstates = " << m_nStates << "" << endl;
+ cout << "Tc = " << abs(m_Tc) << "W/W" << endl;
+ cout << "Ta = " << abs(m_Ta) << "W/W" << endl;
+ cout << "Initial state = " << m_stateCurrent << "" << endl;
cout << (dynamic_cast<spx::oa_signal_type *>(p_in.get_interface()))->name();
cout << " --> ";
cout << (dynamic_cast<spx::oa_signal_type *>(p_out.get_interface()))->name();
@@ -41,7 +43,7 @@ void PCMElement::on_input_changed()
cur_wavelength_id = s.m_wavelength_id;
m_memory_in[cur_wavelength_id] = s.m_field;
- // Summing powers of all wavelengths
+ // Summing powers of all wavelengths (IGNORE heterodyne effects !)
total_in_power = 0;
for (auto lambdaID_field : m_memory_in)
{
@@ -83,7 +85,7 @@ void PCMElement::on_input_changed()
m_last_pulse_power = total_in_power;
// Write attenuated signal to output
- s *= m_transmission;
+ s *= m_Tcurrent_field;
s.getNewId();
m_out_writer.delayedWrite(s, SC_ZERO_TIME);
@@ -105,7 +107,7 @@ bool PCMElement::phase_change(const vector<pulse_sample_t> &samples, const bool
if (samples.empty())
return true;
- if (sc_time_stamp().to_seconds() - samples.back().first < influence_time_ns*1e-9)
+ if (sc_time_stamp().to_seconds() - samples.back().first < m_influence_time_ns*1e-9)
return true;
if (local)
@@ -119,11 +121,11 @@ bool PCMElement::phase_change(const vector<pulse_sample_t> &samples, const bool
energy_absorbed += samples[i].second * dur_pulse;
}
// if enough energy and not saturated
- if ((energy_absorbed > m_meltEnergy) && (m_state < m_nStates))
+ if ((energy_absorbed > m_meltEnergy) && (m_stateCurrent < m_nStates))
{
// cout << sc_time_stamp() << ": \n\t" << name() << " phase changed with "
// << energy_absorbed*1e6 << " uJ" << endl;
- m_state++;
+ m_stateCurrent++;
// cout << "\tnew state: " << m_state << endl;
update_transmission_local();
}
@@ -139,12 +141,9 @@ bool PCMElement::phase_change(const vector<pulse_sample_t> &samples, const bool
void PCMElement::update_transmission_local()
{
- double sp = 0.85;
- double ep = 0.95;
- double speed = 3;
- m_transmission = sp+(ep-sp)*tanh(speed*m_state/m_nStates);
+ m_Tcurrent = m_Tc+(m_Ta-m_Tc)*tanh(m_speed*m_stateCurrent/m_nStates);
// cout << "\tnew trans_power: " << m_transmission << "- W/W" << endl;
// For field need to do a square root
- m_transmission = sqrt(m_transmission);
+ m_Tcurrent_field = sqrt(m_Tcurrent);
}
diff --git a/src/devices/pcm_device.h b/src/devices/pcm_device.h
index 4510591..f746ace 100644
--- a/src/devices/pcm_device.h
+++ b/src/devices/pcm_device.h
@@ -24,33 +24,46 @@ public:
typedef pair<double,double> pulse_sample_t;
// Member variables
- double m_meltEnergy;
- int m_state;
- int m_nStates;
- double m_transmission = 1;
- double influence_time_ns = 1;
+ double m_Tc = 0; /* Transmission (power) in initial (fully crystalline) state */
+ double m_Ta = 1; /* Transmission (power) in final (fully amorphous) state */
+ double m_meltEnergy; /* Programming threshold*/
+ int m_nStates; /* Total number of states */
+ double m_influence_time_ns = 1; /* Duration for which energy is maintained (hard threshold for representing thermal losses)*/
+ double m_speed = 3; /* Parameter affecting the transmission curve and how fast transmission saturates */
+
+ int m_stateCurrent = 0; /* Current state */
+ double m_Tcurrent = 0; /* Current transmission (power) */
+ double m_Tcurrent_field = 0; /* Current transmission (field) */
/** Current information about the optical input, before any attenuation and phase shift. */
- double m_last_pulse_power;
+ double m_last_pulse_power = 0;
std::map<uint32_t,OpticalSignal::field_type> m_memory_in;
-
// Processes
void on_input_changed();
+
+ // Member functions
bool phase_change(const vector<pulse_sample_t> &vec, const bool &local);
void update_transmission_local();
-
// Constructor
PCMElement(sc_module_name name,
double meltEnergy = 0,
int nStates = 0,
- int state = 0)
+ int state = 0,
+ double Tc = 0,
+ double Ta = 0,
+ double influence_window_ns = 1,
+ double speed = 3)
: spx_module(name)
, m_out_writer("out_delayed_writer", p_out)
+ , m_Tc(Tc)
+ , m_Ta(Ta)
, m_meltEnergy(meltEnergy)
- , m_state(state)
, m_nStates(nStates)
+ , m_influence_time_ns(influence_window_ns)
+ , m_speed(speed)
+ , m_stateCurrent(state)
{
SC_HAS_PROCESS(PCMElement);