Commit 35ed1d52 authored by Daniel Brown's avatar Daniel Brown Committed by Sean Leavey
Browse files

fixes #362 always build matrix in simulation by default. Need a better way of...

fixes #362 always build matrix in simulation by default. Need a better way of determining this type of switch, as it makes the logic internally in the simulation difficult
parent 7b954323
......@@ -2433,11 +2433,13 @@ class Model:
# some more refactoring to do with the simulations. Maybe
# BaseSimulation > TraceSimulation > CarrierSignalMatrixSimulation
needs_matrix = (
any(d.needs_fields for d in self.detectors)
or len(tuple(self.get_elements_of_type(_Readout))) > 0
or self.fsig.f.value is not None
)
# TODO ddb forcing this to be true, ends up making logic difficult throughout
# the simulation code with what is and is not allocated
needs_matrix = True # (
# any(d.needs_fields for d in self.detectors)
# or len(tuple(self.get_elements_of_type(_Readout))) > 0
# or self.fsig.f.value is not None
# )
# so far the only simulation we can build is a carrier+signal matrix type
# of simulation. Eventually here we need some logic to decide what to run
# and return the relevant simulation object.
......
......@@ -752,7 +752,7 @@ cdef class MatrixSystemSolver:
return self._M.c_set_rhs(self.field_fast(node_id, freq_idx, hom_idx), value, rhs_index)
cdef int set_source_fast_2(self, Py_ssize_t rhs_idx, complex_t value) except -1:
return self._M.c_(rhs_idx, value, 0)
return self._M.c_set_rhs(rhs_idx, value, 0)
cdef int set_source_fast_3(self, Py_ssize_t rhs_idx, complex_t value, unsigned rhs_index) except -1:
return self._M.c_set_rhs(rhs_idx, value, rhs_index)
......@@ -926,7 +926,7 @@ cdef class CarrierSignalMatrixSimulation:
from finesse.simulations.KLU import KLUMatrixSystemSolver
if self.model.fsig.f.is_changing and self.model.fsig.f.value is None:
#raise Exception(f"Signal frequency is being changed but an initial value has not been set. Set initial value for `fsig` before running.")
LOGGER.warning("Signal frequency (fsig) was set to None but simulation needs it. Setting default value of 1 Hz")
self.model.fsig.f.value = 1
# Keep a list of all the things changing in the simulation
......@@ -944,20 +944,22 @@ cdef class CarrierSignalMatrixSimulation:
# First we sort out the two matrix simulations as required by the model
cf = self.generate_carrier_frequencies()
onodes = self.model.optical_nodes
self.carrier = KLUMatrixSystemSolver("carrier", onodes, cf, None, None, self.model_data.num_HOMs, False, self.model.force_refill)
if self.compute_signals:
nodes = onodes.copy()
nodes.extend(self.model.get_active_elec_mech_nodes())
sf, mf, ef = self.generate_signal_frequencies(nodes, cf)
self.signal = KLUMatrixSystemSolver("signal", nodes, sf, mf, ef, self.model_data.num_HOMs, True, self.model.force_refill)
self.initialise_noise_matrices()
if self.do_matrix_solving:
self.carrier = KLUMatrixSystemSolver("carrier", onodes, cf, None, None, self.model_data.num_HOMs, False, self.model.force_refill)
if self.compute_signals:
nodes = onodes.copy()
nodes.extend(self.model.get_active_elec_mech_nodes())
sf, mf, ef = self.generate_signal_frequencies(nodes, cf)
self.signal = KLUMatrixSystemSolver("signal", nodes, sf, mf, ef, self.model_data.num_HOMs, True, self.model.force_refill)
self.initialise_noise_matrices()
self.initialise_trace_forest(onodes)
self.initialise_workspaces()
self.update_all_parameter_values()
if self.compute_signals:
if self.do_matrix_solving and self.compute_signals:
self.initialise_noise_sources()
self.initialise_noise_selection_vectors()
......
Markdown is supported
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