private void UpdateCheckBoxes() { int i = 1; if (_medium == null) { return; } ArrayList molecules = _medium.getMolecules(); if (molecules == null) { return; } foreach (Molecule mol in molecules) { Vector3 pos = new Vector3(gameObject.transform.position.x - 0.14f, gameObject.transform.position.y + i * 0.05f - 0.07f, gameObject.transform.position.z); Transform CB = Instantiate(_checkBoxPrefab, pos, gameObject.transform.rotation) as Transform; CB.parent = gameObject.transform; CB.name = mol.getName() + "CheckBox"; UILabel l = CB.Find("Label").GetComponent <UILabel>(); l.text = mol.getName(); i++; } }
//! Processing a reaction. /*! * \param molecules A list of molecules (not usefull here) * * A diffusion reaction based on fick model is calculated by using this formula : * dn/dt = c1 - c2 * P * A * Where: * - dn is the difference of concentration that will be applied * - c1 and c2 the concentration the molecules in the 2 Mediums * - P is the permeability coefficient * - A is the contact surface size between the two Mediums */ public override void react(ArrayList molecules) { ArrayList molMed1 = _medium1.getMolecules(); ArrayList molMed2 = _medium2.getMolecules(); Molecule mol2; float c1; float c2; float result; if (_P == 0f || _surface == 0f) { return; } foreach (Molecule mol1 in molMed1) { c1 = mol1.getConcentration(); mol2 = ReactionEngine.getMoleculeFromName(mol1.getName(), molMed2); if (mol2 != null && mol2.getFickFactor() > 0f) { c2 = mol2.getConcentration(); result = (c2 - c1) * _P * _surface * mol2.getFickFactor() * _reactionSpeed * ReactionEngine.reactionsSpeed; if (enableSequential) { mol2.addConcentration(-result); mol1.addConcentration(result); } else { mol2.subNewConcentration(result); mol1.addNewConcentration(result); } } } }
public void setMedium(Medium medium) { _molecules = medium.getMolecules(); if (_molecules == null) return ; foreach (Molecule mol in _molecules) _curves.AddLast(new Curve(mol, gameObject.GetComponent<Transform>().localPosition, _VectrosityCam)); }
/* * \brief This function do the reaction. * \details The ActiveTransportReaction is a reaction that is exactly the same as EnzymeReaction. * The only difference is that the production are added to the destination medium and not to the * medium where the reaction is going on. * \param molecules dont usefull, can be set to null * \sa execEnzymeReaction */ public override void react(ArrayList molecules) { if (!_isActive) { return; } ArrayList molSrcMed = _srcMedium.getMolecules(); ArrayList molDstMed = _dstMedium.getMolecules(); Molecule substrate = ReactionEngine.getMoleculeFromName(_substrate, molSrcMed); if (substrate == null) { return; } float delta = execEnzymeReaction(molSrcMed) * _reactionSpeed * ReactionEngine.reactionsSpeed; float energyCoef; float energyCostTot; if (delta > 0f && _energyCost > 0f && enableEnergy) { energyCostTot = _energyCost * delta; energyCoef = _medium.getEnergy() / energyCostTot; if (energyCoef > 1f) { energyCoef = 1f; } _medium.subEnergy(energyCostTot); } else { energyCoef = 1f; } delta *= energyCoef; if (enableSequential) { substrate.subConcentration(delta); } else { substrate.subNewConcentration(delta); } foreach (Product pro in _products) { Molecule mol = ReactionEngine.getMoleculeFromName(pro.getName(), molDstMed); if (enableSequential) { mol.addConcentration(delta); } else { mol.addNewConcentration(delta); } } }
/*! \brief This method gets all molecular concentrations \sa Molecule \sa Molecule.getConcentration() */ public void initMolecules() { LinkedList<Medium> mediums = _reactionEngine.getMediumList(); _mediumRef = ReactionEngine.getMediumFromId(_mediumId, mediums); if(_mediumRef != null && _molecules == null) { _molecules = _mediumRef.getMolecules(); } }
/*! * \brief This method gets all molecular concentrations * \sa Molecule * \sa Molecule.getConcentration() */ public void initMolecules() { LinkedList <Medium> mediums = _reactionEngine.getMediumList(); _mediumRef = ReactionEngine.getMediumFromId(_mediumId, mediums); if (_mediumRef != null && _molecules == null) { _molecules = _mediumRef.getMolecules(); } }
public void setMedium(Medium medium) { _molecules = medium.getMolecules(); if (_molecules == null) { return; } foreach (Molecule mol in _molecules) { _curves.AddLast(new Curve(mol, gameObject.GetComponent <Transform>().localPosition, _VectrosityCam)); } }
public ArrayList getMoleculesFromMedium(int id) { //"warn" parameter is true to indicate that there is no such Medium //as the one needed to get molecules Medium medium = LinkedListExtensions.Find <Medium>( _mediums , m => m.getId() == id , true , " RE::getMoleculesFromMedium(" + id + ")"); if (medium != null) { return(medium.getMolecules()); } else { return(null); } }
public void setMedium(int mediumId) { if (!safeLazyInit()) { return; } _mediumId = mediumId; Medium medium = ReactionEngine.getMediumFromId(_mediumId, _mediums); if (medium == null) { Logger.Log("VectrosityPanel Can't find the given medium (" + _mediumId + ")", Logger.Level.ERROR); return; } _molecules = medium.getMolecules(); if (_molecules == null) { Logger.Log("VectrosityPanel Can't find molecules in medium (" + _mediumId + ")", Logger.Level.ERROR); return; } VectrosityPanelLine line; foreach (Molecule m in _molecules) { line = _lines.Find(l => m.getName() == l.moleculeName); if (null == line) { _lines.Add(new Line(width, height, infos, _mediumId, m.getName())); } } drawLines(true); lineCount = _lines.Count; }