Commit c27dd555 authored by Félix Hartmann's avatar Félix Hartmann
Browse files

[feature] The polar transport coefficient is now a function of time.

parent 7dd2fc06
......@@ -79,7 +79,7 @@ class JSONCodec():
if json_obj["__class__"] == "ControlPanel":
del json_obj["__class__"]
return json_obj
# the two following elif blocks are for backward campatibility
# the following elif blocks are here for backward campatibility
elif json_obj["__class__"] == "DiffusiveSignal":
del json_obj["__class__"]
D = json_obj["d_intracell"]
......@@ -104,6 +104,15 @@ class JSONCodec():
obj.set(**json_obj)
obj.d_function = Constant(constant_value=d)
return obj
elif json_obj["__class__"] == \
"SimpleUnidirectionalActiveTransport" and "p" in json_obj:
del json_obj["__class__"]
p = json_obj["p"]
del json_obj["p"]
obj = SimpleUnidirectionalActiveTransport()
obj.set(**json_obj)
obj.p_function = Constant(constant_value=p)
return obj
for key, value in self.class_dict.items():
if json_obj["__class__"] == value:
del json_obj["__class__"]
......@@ -179,8 +188,6 @@ def growth(simu):
simu.start_time + (nb_input_samples - 1) *
simu.input_time_step / time_units["day"],
nb_input_samples)
# activation_time_for_simu = \
# (simu.activation_time - simu.start_time) * time_units["day"]
simu.cell_file = CellFile(
nb_cells=simu.nb_cells,
initial_CRD=simu.cell_diameter,
......
......@@ -191,3 +191,11 @@ class FunctionHandler(Handler):
info.object.d_evolution,
info.object.d_function,
"d_function")
def object_p_evolution_changed(self, info):
if not hasattr(info.object, "p_evolution"):
return None
self.replace_evolution_function(info.object,
info.object.p_evolution,
info.object.p_function,
"p_function")
......@@ -58,12 +58,12 @@ class UniformDiffusion(Transport):
Of course, this medium is growing nonuniformly.
"""
time = 0
time = 0 # necessary for time-varying parameters
D = Float(0.1,
label="Diffusion coefficient (µm.s¯²)",
desc="diffusion coefficient of the signal, in µm.s¯², "
"constant along the whole file.")
"uniform along the whole file.")
# type of evolution function for the decay rate
d_evolution = Enum(
......@@ -130,6 +130,7 @@ class UniformDiffusion(Transport):
def set_values(self, start, stop, num):
"""
Set the values of the time-varying parameters.
"""
self.set_d_values(start, stop, num)
......@@ -171,10 +172,62 @@ class SimpleUnidirectionalActiveTransport(Transport):
Transport mechanism described in Grieneisen et al., 2012,
doi: 10.1186/1752-0509-6-37
"""
p = Float(19,
label="Polar transport (µm.s¯¹)",
desc="coefficient accounting for the action of polar efflux "
"carriers, in µm.s¯¹.")
time = 0 # necessary for time-varying parameters
# type of evolution function for the polar transport coefficient p
p_evolution = Enum(
"constant",
"exponential decay",
"log-normal",
"user-defined",
label="Evolution of the polar transport",
desc="type of evolution function for the polar transport coefficient"
"of the signal, coefficient accounting for the action of polar"
"efflux carriers, in µm.s¯¹.")
_function_dict = {
"constant": Constant,
"log-normal": LogNormal,
"exponential decay": Exponential,
"user-defined": UserDefined}
p_function = Instance(EvolutionFunction)
def _p_function_default(self):
return self._function_dict[self.p_evolution]()
# This dictionary is intended to the FunctionHandler instance assigned to
# the traits_view's handler attribute.
_dict_for_functionhandler = {
"evolution": "p_evolution",
"function": "p_function"}
# polar transport coefficient values
p_values = None
def compute_p_values(self, start, stop, num):
"""
Compute the values taken by the polar transport coefficient during the
simulation.
"""
X = np.linspace(start, stop, num)
return self.p_function.f(X)
def set_p_values(self, start, stop, num):
"""
Set the values taken by the polar transport coefficient during the
simulation.
"""
self.p_values = self.compute_p_values(start, stop, num)
@property
def p(self):
return self.p_values[self.time]
@p.setter
def p(self):
raise AttributeError("Sorry, the decay rate can not assigned that way."
"Use the p_function trait instead.")
q = Float(1,
label="Permeability rate (µm.s¯¹)",
......@@ -193,21 +246,51 @@ class SimpleUnidirectionalActiveTransport(Transport):
carrier_orientation = Enum(
"toward the cambium",
"toward the xylem",
label="Corrier orientation",
label="Carrier orientation",
desc="in which direction the carriers are oriented.")
only_in_cambial_cells = Bool(
label="Polar transport only in cambial cells",
desc="if polar transport is limited to cambial cells.")
def set_values(self, start, stop, num):
"""
Set the values of the time-varying parameters.
"""
self.set_p_values(start, stop, num)
general_group = Group(Item('d'),
Item('q'),
Item('p_evolution'),
springy=True)
function_group = Group(
Group(
Item('p_function',
style='custom',
springy=True,
show_label=False
),
show_labels=False
),
label="Definition of the evolution function",
springy=True,
show_border=True
)
traits_view = View(
Item('p'),
Item('q'),
Item('d'),
# Item('s'),
Item('carrier_orientation'),
Item('only_in_cambial_cells'),
resizable=True)
Group(
general_group,
function_group,
# Item('plot_function', show_label = False),
# Item('s'),
Item('carrier_orientation'),
Item('only_in_cambial_cells'),
springy=True
),
handler=FunctionHandler(),
resizable=True
)
# end of the SimpleUnidirectionalActiveTransport class
......
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