src/context.jl
MEDYAN.MembraneSpeciesParams
Membrane protein physical parameters.
diffusion_coeff::Float64
: Membrane diffusion coefficients (nm^2/s).area::Float64
: Protein area projected onto the surface (nm^2).kbend::Float64
: Bending rigidity (pN nm).eqcurv::Float64
: The protein’s own spontaneous mean curvature (/nm). Can be used in bending energy computations with curvatures.
Base.copy
Shallow copy, https://stackoverflow.com/questions/51956958/how-to-copy-a-struct-in-julia
MEDYAN.Context
agent_names::MEDYAN.AgentNames
sys_def::MEDYAN.SysDef
compartments::Vector{MEDYAN.Compartment}
grid::Any
time::Ref{Float64}
: time (s)stats::MEDYAN.PerformanceStats
β::Float64
: inverse kT (1/(nm*pN))base_diffusion_coeffs::Vector{Float64}
: Diffusion coefficients indexed by diffusing species id (nm²/s)membrane_species_params::StaticArraysCore.SVector{NUM_MEMBRANEDIFFUSINGSPECIES, MEDYAN.MembraneSpeciesParams} where NUM_MEMBRANEDIFFUSINGSPECIES
: Membrane species parameters indexed by membrane diffusing species id.min_compartment_volume_ratio::Float64
: Smallest volume a compartment can have before being deactivated as a ratio to a full compartment volume.chemistryengine::MEDYAN.RDMESampler
: The reaction diffusion master equation sampler, contains the diffusing and regular fixed species statelargestfilamentid::Vector{Int64}
: The largest filament id, indexed by filament type idchem_cylinders::Vector{MEDYAN.ChemCylinders}
: Data about filament cylinders, indexed by filament type idmembranes::Vector
: All membrane meshes.link_manager::MEDYAN.LinkManager
link_2mon_data::Tuple{Vararg{MEDYAN.Link2MonData}}
: The linked link2mon parameters, indexed by link2mon type id, to give a Link2MonDatadecimated_2mon_site_managers::Tuple{Vararg{MEDYAN.AbstractDecimated2MonSiteManager}}
: Site managers, indexed by site idlinked_monomers::Dictionaries.Dictionary{MEDYAN.MonomerName, Vector{Vector{Int64}}}
: Dictionary of all monomers that have a bound link2mon. indexed by monomer name, then link2montypeid, to give a vector of unique link2mon ids that reference the monomer namefilamentsites::Tuple{Vararg{Tuple{Vararg{MEDYAN.SiteData}}}}
: The filament site definitions, indexed by filament type id, filament site id to get a SiteData with fields of id, site, fxsidfilamentendsites::Tuple{Vararg{Tuple{Vararg{MEDYAN.SiteData}}}}
: The filamentend site definitions, indexed by filament type id, filamentend site id to get a SiteData with fields of id, site, fxsidmaxfilsite_plusrange::Vector{Int64}
: The maximum plus range in monomers that any filament site or end site can see. Indexed by filament type idmaxfilsite_minusrange::Vector{Int64}
: The maximum minus range in monomers that any filament site or end site can see. Indexed by filament type idmembranesites::Tuple{Vararg{MEDYAN.SiteData}}
: Maps membrane site id to a SiteData with fields of id, site, fxsid.map_membranediffusingspeciesindex_membranesiteindices::Tuple{Vararg{Vector{Int64}}}
: Maps membrane diffusing species index to a list of membrane sites using this species as reactant. This is initialized during context init and should not be changed.link_2mon_sites::Tuple{Vararg{Tuple{Vararg{MEDYAN.SiteData}}}}
: Site definitions, indexed by link_2mon type id, site id to get a SiteData with fields of id, site, fxsidmon_link_2mon_sites::Tuple{Vararg{Tuple{Vararg{MEDYAN.SiteData}}}}
: Site definitions, indexed by link_2mon type id, site id to get a SiteData with fields of id, site, fxsidchem_max_search_dist::Float64
decimated_2mon_sites::Tuple{Vararg{MEDYAN.SiteData}}
: Site definitions, indexed by site id to get a SiteData with fields of id, site, fxsidcadherinsites::Tuple{Vararg{Tuple{Vararg{MEDYAN.SiteData}}}}
cadherindata::Tuple{Vararg{MEDYAN.CadherinData}}
possiblecadherinsite_managers::Tuple{Vararg{MEDYAN.AbstractPossibleCadherinSiteManager}}
: Site managers, indexed by site idcadherinlinked_vertices::Dictionaries.Dictionary{MEDYAN.VertexName, Vector{Vector{Pair{MEDYAN.VertexName, MEDYAN.MonomerName}}}}
: Dictionary of all vertices that have a bound cadherin. indexed by vertex name, then cadherintypeid, to give a vector of unique cadherin endnames that reference the monomer name and vertex namecheck_sitecount_error::Bool
: If true site counts are checked for errors on every chem update. This is extremely slow, but useful for testing chem update errors.compartmentreactioncallbacks::Any
bulkreactioncallbacks::Any
memdiff_bulks_index::Int64
: Mock bulk species index for membrane diffusion.viscosity::Float64
: viscosity (pNs/nm² or MPas) water is about 1E-9g_tol::Float64
: maximum force magnitude after minimization (pN)shake_before_minimization::Bool
: If true, add noise to coordinates before starting minimization.iter_max_cg_minimization::Int64
: Max number of steps in conjugate gradient minimization.maxstep::Float64
: max step to take during line search (nm)max_cylinder_force::Float64
: max cylinder force when two cylinders are at zero distance (pN)check_neighborlist_error::Bool
: If true neighborlists are checked for errors on every force calc. This is extremely slow, but useful for testing neighborlist errors.nthreads::Int64
: Experimental Set to more than 1 to enable multi threading. This is currently may result in non bitwise reproducable simulations. Results should be statistcally identical, but this is currently not well tested.enable_cylinder_volume_exclusion::Ref{Bool}
: Are cylinder volume exclusion forces calculatedenable_triangle_bead_volume_exclusion::Bool
: Are triangle-bead volume exclusion forces calculated.cylinder_skin_radius::Float64
: Extra cell list cutoff radius in nm. The cell lists are reset after a bead moves over this amountfilamentmechparams::Vector{MEDYAN.FilamentMechParams}
: The filament mechanical parameters, indexed by filament type idmembranemechparams::Vector{MEDYAN.MembraneMechParams}
: Membrane mechanical parameters, indexed by membrane type id.func_membranespeciespotentialenergy::Any
: Membrane species potential energy function. See docs on default function for more info.membranefilamentmechparams::MEDYAN.MembraneFilamentMechParams
: Membrane-filament mechanical interaction parameters.external_energy_forces!::Any
: External energy/force expressions. This should be a mutating function taking a(fc::MEDYAN.ForceContext)
, which adds tofc.forces, fc.energies, and fc.energy
. The energy and force must be consistent, and this is not checked. This can be used as ad-hoc solutions to experiment with uncommon forces, such as specifically designed attachments, etc. If this variable is used often, consider moving it into MEDYAN.chemboundary::MEDYAN.Boundary
: chemical boundary, updates compartment volumes and diffusion ratesmeshindex_as_chemboundary::Ref{Int64}
: The membrane index used as chemical boundary. If values other than 0 is used, the actual interior region of the chemical boundary is the intersection between- the interior of
chemboundary
, and - the interior of the membrane mesh at this index.
Note: Since the membrane may change its shape often,
set_chemboundary!
might need to be called often accordingly to update volumes of compartments.- the interior of
mechboundary::MEDYAN.Boundary
: mechanical boundarysharedtypedconfigs::MEDYAN.SharedTypedConfigs
: Shared configurations stored in type parameters.validflags::MEDYAN.ValidFlags
: Interval system consistency validation flags.
MEDYAN.num_filtypes
MEDYAN.filtype_fil_ids
MEDYAN.fil_node_positions
MEDYAN.fil_node_mon_ids
Return the node monomer ids of the filament.
The fil_node_mon_ids
are the monomer ids at (slightly plus side of) the fil_node_positions
|
-----+-----|-----+-----
minus end <---- M | M | (M) | M ----> plus end
-----+-----|-----+-----
|
^ A node position is indicated by the line.
The monomer id with parenthesis (M) will in `fil_node_mon_ids`
The first monomer id is the first monomer id on the filament. The last monomer id is the last monomer id on the filament + 1
MEDYAN.fil_mon_states
MEDYAN.fil_num_unmin_ends
Return a tuple (minus, plus) of the number of unminimized monomers on the minus and plus end of a filament.
This will be reset to (0, 0) by minimize_energy!
When an end is depolymerized this will decrease, but saturate at 0. When an end is polymerized this will increase.
For example if after minimization a filament has a plus end depolymerization, this function will return (0, 0). Then if a plus end polymerization happens, this function will return (0, 1), even though the net change in filament length is zero.
MEDYAN.vertex_state
MEDYAN.mon_exists
MEDYAN.mon_minimized
MEDYAN.mon_3states
MEDYAN.mon_position
MEDYAN.mon_plusvector
MEDYAN.mon_position_plusvector
MEDYAN.link_2mon_endnames
MEDYAN.link_2mon_state
MEDYAN.set_time!
MEDYAN.set_enable_cylinder_volume_exclusion!
MEDYAN.set_chemboundary!
Set chemical boundary and update compartment volumes and diffusion rates. Note, the chemboundary should be outside the mechboundary so that it is rare for filaments to go outside the chemboundary
See also Boundary
Keywords
planes::Vector{SVector{4,Float64}} = []
Planes that make up the chemical boundary of the simulation
inside = signbit(pos ⋅ planes[bi][1:3] - planes[bi][4])
For example, a plane [1,0,0,3]
is inside if x < 3 nm.
2.0*[1,0,0,3]
is also inside if x < 3 nm.
capsules::Vector{SVector{8,Float64}} = []
Capsules that make up the chemical boundary of the simulation.
capsules[bi][1:3]
is the starting point of the spine line segment (nm). capsules[bi][4:6]
is the axis of the spine line segment (nm). capsules[bi][7]
is the radius (nm). capsules[bi][8]
is ignored.
if capsules[bi][4:6]
is zero then the capsule is a sphere. Capsule boundaries can be combined with plane boundaries to create cylinder boundaries.
meshindex_as_chemboundary::Int = 0
: Index of membrane mesh that further restricts the chem boundary. 0 for none.
The system geometry information must be up-to-date. This mesh index is not stored in the boundary object, but is directly set in the context.
MEDYAN.set_mechboundary!
See also Boundary
MEDYAN.chem_adddiffusingcount!
MEDYAN.chem_addfixedcount!
MEDYAN.adddiffusingcount_rand!
MEDYAN.addmembranediffusingcount_rand!
MEDYAN.newfilament_rand!
Add a filament with type id ftid
to the Context with random center position and direction.
Return the filament id of a new filament.
monomerstates
is a collection of the MonomerState
of the monomers in the new filament.
The filament will be inside the mech boundary.
Errors if it fails to add a filament.
The monomer are spaced by the value in the filament type’s mechanical parameters.
MEDYAN.run_chemistry!
MEDYAN.defer_chem_caching!
This should only be used for advanced optimizations.
During chemistry, the context mutating functions will typically try to avoid invalidating various cached data needed to quickly sample sites.
However, if you want to mutate the context outside of chemistry, for example right before or after minimization, you may not want to pay the cost of revalidating all the caches because minimization will already invalidate the caches. Caching will be enabled again and caches will be made valid the next time chemistry is run. Caching can also be manually refreshed and reenabled with: refresh_chem_cache!
MEDYAN.refresh_chem_cache!
MEDYAN.is_chem_cache_valid
Base.empty!
MEDYAN.chem_setmonomerstate!
MEDYAN.chem_polymerize!
Add a monomer with state newstate
to the end of the filament with type id ftid
and id fid
.
If isminusend
is true
add the monomer to the minus end of the filament, if false
add it to the plus end of the filament.
This doesn’t affect the other monomer states, positions, linked link_2mons, or change any of the monomer names. New monomers are not linkable until after minimization.
MEDYAN.chem_depolymerize!
Remove a monomer from the end of the filament with type id ftid
and id fid
.
If isminusend
is true
remove the monomer from the minus end of the filament, if false
remove it from the plus end of the filament.
This doesn’t affect the other monomer states, positions, linked link_2mons, or change any of the monomer names.
Error if the filament isn’t initially over 2 monomers long.
Warn if the old end monomer is referenced in a link2mon, and remove the link2mon.
The warning can be disabled by passing keyword argument warniflink_2mon_removed=false
MEDYAN.chem_newlink_2mon!
chem_newlink_2mon!(c::Context, ltid::Int, endnames::Pair{MonomerName,MonomerName}, link_2mon_state::Link2MonState;
new_lid::Union{Nothing,Int64} = nothing,
)::Int64
chem_newlink_2mon!(c::Context, ltid::Int, endnames::Pair{MonomerName,MonomerName};
changedchemstate = (;),
changedmechstate = (;),
is_minimized = c.link_2mon_data[ltid].params.defaultstate.is_minimized,
new_lid::Union{Nothing,Int64} = nothing,
)::Int64
Add a new link_2mon with type id ltid
between monemers endnames
.
Return the link_2mon id.
Error if a link_2mon of the same type links the same monomers in the same order.
If the link2mon state isn’t provided, c.link*2mon*data[ltid].params.defaultstate
is new link2mon’s state, optionally modified by the changedchemstate
, changedmechstate
, and is_minimized
keyword arguments.
Keyword arguments changedchemstate
and changedmechstate
are namedtuples that shadow fields from the default chemstate and mechstate for the new link_2mon.
Keyword argument is_minimized
can be used to set the new link*2mon’s is*minimized
state.
Keyword argument new_lid
can be optionally used to set the new link_2mon’s id, if this id is currently used, error.
Example
MEDYAN.chem_removelink_2mon!
MEDYAN.chem_setlink_2mon_state!
MEDYAN.chem_newfilament!
Return the filament id of a new filament.
Error if the filament isn’t initially over 2 monomers long.
Newly added filaments don’t have decimated_2mon sites, until after minimization.
Keyword Arguments
ftid=1
: filament type id.monomerstates
: Collection of theMonomerState
of the monomers in the new filament. In order from minus end to plus end.length(monomerstates)>1
nodepositions
: Collection ofSVector{3,Float64}
. The positions of the nodes, monomers are between nodes.node_mids
: Collection ofInteger
. The monomer ids at (slightly plus side of) thenodepositions
| -----+-----|-----+----- minus end <---- M | M | (M) | M ----> plus end -----+-----|-----+----- | ^ A nodeposition is indicated by the line.
The monomer id with parenthesis (M) will in
node_mids
length(node_mids) == length(nodepositions) - 1
endloadforces=(0.0=>0.0)
: end load forces, usually don’t use this, because load forces will automatically get updated at the next minimization.
MEDYAN.chem_removefilament!
Remove the filament with type id ftid
and id fid
.
By default the last added filament with type id ftid
is removed.
Warn if any monomers on the filament are referenced by any link2mons, and remove those link2mons.
The warning can be disabled by passing keyword argument warniflink_2mon_removed=false
MEDYAN.newmembrane!
Add a new membrane to the system.
Keyword arguments
meshinit
is structure containing mesh shape initialization information, such as a named tuple(vertlist, trilist)
containing vertex coordinates and triangle list,MeshInitEllipsoid
,MeshInitPlane
or a generalMeshInitSurfaceFunc
.