Class ConcentrationBasedModule<DeltaFunctionType extends AbstractDeltaFunction>
- java.lang.Object
-
- bio.singa.simulation.model.modules.AbstractUpdateModule
-
- bio.singa.simulation.model.modules.concentration.ConcentrationBasedModule<DeltaFunctionType>
-
- All Implemented Interfaces:
UpdateModule,Runnable
- Direct Known Subclasses:
Diffusion,EndocytoticPitAbsorption,LateralMembraneDiffusion,MembraneDiffusion,PorousDiffusion,Reaction,SingleFileChannelMembraneTransport
public abstract class ConcentrationBasedModule<DeltaFunctionType extends AbstractDeltaFunction> extends AbstractUpdateModule
Concentration based modules handle updates that are applied to the concentrations inUpdatables during a simulation. Each module has aUpdateScopethat regulates the dependence of this module to other parts of the simulation. Further, theUpdateSpecificitydefines how fine-grained the updates are calculated. New modules should be created with theModuleFactory.- Author:
- cl
-
-
Field Summary
Fields Modifier and Type Field Description protected FieldSuppliersupplierFrequently required fields.
-
Constructor Summary
Constructors Constructor Description ConcentrationBasedModule()Creates a new concentration based module.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddDeltaFunction(DeltaFunctionType deltaFunction)Adds a delta function to the module.voidcalculateUpdates()booleandeltaIsValid(ConcentrationDelta delta)Returns true if the delta is valid, i.e.NumericalErrordetermineLargestLocalError()The local error is calculated and the largest local error of the current epoch resulting from the executing module is returned.Predicate<Updatable>getApplicationCondition()Returns the application condition for this module.The module is only evaluated if the updatable fulfills the given predicate.CellSubsectiongetRestrictedSubsection()protected doublegetScaledFeature(ChemicalEntity entity, Class<? extends bio.singa.features.model.AbstractScalableQuantitativeFeature<?>> featureClass)Returns the requested feature of the given chemical entities, scaled according to the current time step and spatial scaling.doublegetScaledFeature(Class<? extends bio.singa.features.model.AbstractScalableQuantitativeFeature<?>> featureClass)UpdateScopegetScope()Returns the scope of this module.UpdateSpecificitygetSpecificity()Returns the specificity of this module.FieldSuppliergetSupplier()Returns the field supplier.voidhandleDelta(ConcentrationDeltaIdentifier deltaIdentifier, ConcentrationDelta delta)Handles a delta based on the current state of the calculation.voidinBetweenHalfSteps()voidinitialize()voidonCompletion()voidonReset()voidoptimizeTimeStep()voidrestrictApplication()protected voidsetApplicationCondition(Predicate<Updatable> applicationCondition)Sets the application condition for this module.voidsetRestrictedSubsection(CellSubsection restrictedSubsection)-
Methods inherited from class bio.singa.simulation.model.modules.AbstractUpdateModule
addEvidence, addReferencedEntities, addReferencedEntity, checkFeatures, equals, getEvidence, getFeature, getFeatureManager, getFeatures, getIdentifier, getReferencedChemicalEntities, getRequiredFeatures, getSimulation, getState, hashCode, reset, run, setEvidence, setFeature, setFeatureManager, setIdentifier, setSimulation, setState, toString
-
-
-
-
Field Detail
-
supplier
protected FieldSupplier supplier
Frequently required fields.
-
-
Method Detail
-
addDeltaFunction
protected void addDeltaFunction(DeltaFunctionType deltaFunction)
Adds a delta function to the module. Delta functions are applied according toUpdateScopeandUpdateSpecificity.- Parameters:
deltaFunction- The delta function.
-
getApplicationCondition
public Predicate<Updatable> getApplicationCondition()
Returns the application condition for this module.The module is only evaluated if the updatable fulfills the given predicate.- Returns:
- The application condition.
-
setApplicationCondition
protected void setApplicationCondition(Predicate<Updatable> applicationCondition)
Sets the application condition for this module. The module is only evaluated if the updatable fulfills the given predicate.- Parameters:
applicationCondition- The application condition.
-
getSupplier
public FieldSupplier getSupplier()
Returns the field supplier.- Returns:
- The field supplier.
-
getScope
public UpdateScope getScope()
Returns the scope of this module.- Returns:
- The scope of this module.
-
getSpecificity
public UpdateSpecificity getSpecificity()
Returns the specificity of this module.- Returns:
- The specificity of this module.
-
handleDelta
public void handleDelta(ConcentrationDeltaIdentifier deltaIdentifier, ConcentrationDelta delta)
Handles a delta based on the current state of the calculation.- Parameters:
deltaIdentifier- The unique identifier of the delta.delta- The delta itself.
-
deltaIsValid
public boolean deltaIsValid(ConcentrationDelta delta)
Returns true if the delta is valid, i.e. it is not zero and nor below the numerical threshold.- Parameters:
delta- The delta to be evaluated.- Returns:
- true if the delta is valid, i.e. it is not zero and nor below the numerical threshold.
-
determineLargestLocalError
public NumericalError determineLargestLocalError()
The local error is calculated and the largest local error of the current epoch resulting from the executing module is returned. The local error is calculated according to the midpoint method E = abs(1 - (fullDelta / halfDelta)). If the difference is large the error is large and vice versa.- Returns:
- The calculated local error.
- Throws:
NumericalInstabilityException- if any of the encountered errors is the result of an numerical instability.
-
calculateUpdates
public void calculateUpdates()
- Specified by:
calculateUpdatesin classAbstractUpdateModule
-
optimizeTimeStep
public void optimizeTimeStep()
- Specified by:
optimizeTimeStepin classAbstractUpdateModule
-
inBetweenHalfSteps
public void inBetweenHalfSteps()
-
getScaledFeature
public double getScaledFeature(Class<? extends bio.singa.features.model.AbstractScalableQuantitativeFeature<?>> featureClass)
- Overrides:
getScaledFeaturein classAbstractUpdateModule
-
getScaledFeature
protected double getScaledFeature(ChemicalEntity entity, Class<? extends bio.singa.features.model.AbstractScalableQuantitativeFeature<?>> featureClass)
Returns the requested feature of the given chemical entities, scaled according to the current time step and spatial scaling.- Parameters:
entity- The chemical entity.featureClass- The requested feature.- Returns:
- The scaled feature.
-
initialize
public void initialize()
-
restrictApplication
public void restrictApplication()
-
getRestrictedSubsection
public CellSubsection getRestrictedSubsection()
-
setRestrictedSubsection
public void setRestrictedSubsection(CellSubsection restrictedSubsection)
-
onReset
public void onReset()
-
onCompletion
public void onCompletion()
-
-