-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d440ea2
commit 51391a3
Showing
3 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
from glotaran.builtin.megacomplexes.decay.decay_megacomplex import DecayMegacomplex | ||
from glotaran.builtin.megacomplexes.decay.decay_parallel_megacomplex import ( | ||
DecayParallelMegacomplex, | ||
) | ||
from glotaran.builtin.megacomplexes.decay.decay_sequential_megacomplex import ( | ||
DecaySequentialMegacomplex, | ||
) |
40 changes: 40 additions & 0 deletions
40
glotaran/builtin/megacomplexes/decay/decay_parallel_megacomplex.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""This package contains the decay megacomplex item.""" | ||
from __future__ import annotations | ||
|
||
from typing import List | ||
|
||
import numpy as np | ||
|
||
from glotaran.builtin.megacomplexes.decay.decay_megacomplex_base import DecayMegacomplexBase | ||
from glotaran.builtin.megacomplexes.decay.irf import Irf | ||
from glotaran.builtin.megacomplexes.decay.k_matrix import KMatrix | ||
from glotaran.model import DatasetModel | ||
from glotaran.model import megacomplex | ||
from glotaran.parameter import Parameter | ||
|
||
|
||
@megacomplex( | ||
dimension="time", | ||
properties={ | ||
"compartments": List[str], | ||
"rates": List[Parameter], | ||
}, | ||
dataset_model_items={ | ||
"irf": {"type": Irf, "allow_none": True}, | ||
}, | ||
register_as="decay-parallel", | ||
) | ||
class DecayParallelMegacomplex(DecayMegacomplexBase): | ||
def get_compartments(self, dataset_model: DatasetModel) -> list[str]: | ||
return self.compartments | ||
|
||
def get_initial_concentration(self, dataset_model: DatasetModel) -> np.ndarray: | ||
return np.ones((len(self.compartments)), dtype=np.float64) | ||
|
||
def get_k_matrix(self) -> KMatrix: | ||
size = len(self.compartments) | ||
k_matrix = KMatrix() | ||
k_matrix.matrix = { | ||
(self.compartments[i], self.compartments[i]): self.rates[i] for i in range(size) | ||
} | ||
return k_matrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters