def CompileP1(self): """! @brief This compiles the solver for the Heccer core Compile level 1 primarily deals with using a heccer translation service to convert compartments into an intermeidate format. """ if self.GetCore() is not None: if self._compiled_p1 is False: if self._heccer_core.pts is None: return #raise errors.HeccerCompileError("No Heccer translation service present, can't construct an intermediary from the model") result = heccer_base.HeccerCompileP1(self.GetCore()) if result == 0: raise errors.CompileP1Error("Can't compile heccer into an intermediary format") else: self._compiled_p1 = True else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def SetParameter(self, path, field, value): """! @brief Returns the Heccer Address variable """ address = None if self.GetCore() is None: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError() elif self._model_source is None: from errors import HeccerAddressError raise HeccerAddressError(path, field) else: serial = self._model_source.GetSerial(path) result_msg = heccer_base.HeccerAddressableSet(self.GetCore(), serial, field, value) if not result_msg is None: raise Exception(result_msg) return True
def GetParameter(self, path, field): """! @brief Returns the Heccer Address variable """ address = None if self.GetCore() is None: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError() elif self._model_source is None: from errors import HeccerAddressError raise HeccerAddressError(path, field) else: serial = self._model_source.GetSerial(path) value = heccer_base.HeccerAddressGetValue(self.GetCore(), serial, field) return value
def GetTimeStep(self): if self.GetCore() is not None: return self.GetCore().dStep else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def GetStatus(self): """! @brief """ if self.GetCore() is not None: return self.GetCore().iStatus else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def SetName(self, name): """! @brief """ if self.GetCore() is not None: self.GetCore().pcName = name else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def Initiate(self): """! @brief """ if self.GetCore() is not None: heccer_base.HeccerInitiate(self.GetCore()) else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError("Can't initiate, Heccer not allocated")
def SetTimeStep(self, dt): """! @brief """ if self.GetCore() is not None: self.GetCore().dStep = dt else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def WriteToFile(self, filename): """! @brief Writes out heccer to a file """ if self.GetCore() is not None: heccer_base.HeccerWriteToFile(self.GetCore(), filename) else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def DumpV(self): """! """ if self.GetCore() is not None: heccer_base.HeccerDumpV(self.GetCore()) else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def Step(self, time): """! @brief """ if self.GetCore() is not None: return heccer_base.HeccerHeccs(self.GetCore(), time) else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def Dump(self, file, selection): """! """ my_file = None if self.GetCore() is not None: if file == 0: my_file = None heccer_base.HeccerDump(self.GetCore(), my_file, selection) else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def GetCompartmentAddress(self, intermediary=-1, field="Vm"): """! @brief Returns the Heccer Address variable """ address = None if self.GetCore() is None: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError() else: if intermediary == -1: raise Exception("Invalid intermediary index '%d'" % intermediary) serial = -1 if not isinstance(intermediary, int): serial = self._model_source.GetSerial(intermediary) else: serial = intermediary address = heccer_base.HeccerAddressCompartmentVariable(self.GetCore(), serial, field) if address == None: from errors import HeccerAddressError raise HeccerAddressError(str(intermediary), field) return address
def CompileAll(self): """! @brief This compiles the solver for the Heccer core """ heccer_core = self.GetCore() if heccer_core is not None: if not self.IsConstructed(): self.Construct() self.CompileP1() self.CompileP2() self.CompileP3() else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def GetAddress(self, path, field): """! @brief Returns the Heccer Address variable """ address = None if self.GetCore() is None: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError() elif self._model_source is None: from errors import HeccerAddressError raise HeccerAddressError(path, field) else: serial = self._model_source.GetSerial(path) # check serial value, exception? address = heccer_base.HeccerAddressVariable(self.GetCore(), serial, field) if address == None: from errors import HeccerAddressError raise HeccerAddressError(serial, field) return address
def CompileP3(self): """! @brief This compiles the solver for the Heccer core """ if self.GetCore() is not None: if self._compiled_p3 is False: result = heccer_base.HeccerCompileP3(self.GetCore()) if result == 0: raise errors.CompileP3Error("Can't compile intermediary into byte code") else: self._compiled_p3 = True else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def CompileP2(self): """! @brief This compiles the solver for the Heccer core """ if self.GetCore() is not None: if self._compiled_p2 is False: result = heccer_base.HeccerCompileP2(self.GetCore()) if result == 0: raise errors.CompileP2Error("Can't analyze the model and build indexes for optimization") else: self._compiled_p2 = True else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError()
def Construct(self, model=None): """ @brief Constructs heccer from the options """ if self.GetCore() is not None: heccer = self.GetCore() else: from errors import HeccerNotAllocatedError raise HeccerNotAllocatedError() if self.GetOptions() is not None: options = self.GetOptions() else: from errors import HeccerOptionsError raise HeccerOptionsError("Heccer Options are not allocated") # Here we connect the model to heccer model_source = None if model is not None: try: model_source = model.GetCore() except TypeError: model_source = model elif self._model_source is not None: try: model_source = self._model_source.GetCore() except TypeError: model_source = self._model_source else: from errors import HeccerOptionsError raise HeccerOptionsError("Model not found, cannot construct a Heccer") # Probably need to check allow options to be passed to the next two # args model_name = heccer.pcName result = heccer_base.HeccerConstruct( heccer, model_source, model_name, None, None ) if result == 1: self._is_constructed = True return result