/* ----------------------------------------------------------------------
NUFEB package - A LAMMPS user package for Individual-based Modelling of Microbial Communities
Contributing authors: Bowen Li & Denis Taniguchi (Newcastle University, UK)
Email: bowen.li2@newcastle.ac.uk & denis.taniguchi@newcastle.ac.uk
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
------------------------------------------------------------------------- */
#include <math.h>
#include <string.h>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <vector>
#include "atom.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "input.h"
#include "lammps.h"
#include "math_const.h"
#include "memory.h"
#include "bio.h"
#include "atom_vec_bio.h"
#include "fix_bio_kinetics.h"
#include "fix_bio_kinetics_monod.h"
#include "modify.h"
#include "pointers.h"
#include "update.h"
#include "variable.h"
#include "group.h"
using namespace LAMMPS_NS;
using namespace FixConst;
using namespace MathConst;
using namespace std;
enum{HET, AOB, NOB, ANA, COM, EPS, DEAD, CYANO, ECW};
/* ---------------------------------------------------------------------- */
FixKineticsMonod::FixKineticsMonod(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) {
avec = (AtomVecBio *) atom->style_match("bio");
if (!avec)
error->all(FLERR, "Fix kinetics requires atom style bio");
if (narg < 3)
error->all(FLERR, "Not enough arguments in fix kinetics/growth/monod command");
species = NULL;
growrate = NULL;
eps_dens = 30;
eta_het = 0;
suc_exp = 0;
gco2_flag = 0;
kinetics = NULL;
external_gflag = 1;
int iarg = 3;
while (iarg < narg){
if (strcmp(arg[iarg],"gflag") == 0) {
external_gflag = force->inumeric(FLERR, arg[iarg+1]);
if (external_gflag != 0 && external_gflag != 1)
error->all(FLERR, "Illegal fix kinetics/growth/monod command: gflag");
iarg += 2;
} else if (strcmp(arg[iarg],"epsdens") == 0){
eps_dens = force->numeric(FLERR, arg[iarg+1]);
if (eps_dens <= 0)
error->all(FLERR, "Illegal fix kinetics/growth/monod command: eps_dens cannot be less or equal than zero");
iarg += 2;
} else if (strcmp(arg[iarg],"etahet") == 0){
eta_het = force->numeric(FLERR, arg[iarg+1]);
if (eta_het < 0)
error->all(FLERR, "Illegal fix kinetics/growth/monod command: eta_het cannot be less than zero");
iarg += 2;
} else if (strcmp(arg[iarg], "sucexp") == 0){
suc_exp = force->numeric(FLERR, arg[iarg+1]);//suc_exp = input->variable->compute_equal(arg[iarg+1]);
if (suc_exp < 0)
error->all(FLERR, "Illegal fix kinetics/growth/monod command: suc_exp cannot be less than zero");
iarg += 2;
} else if (strcmp(arg[iarg], "gco2flag") == 1){
gco2_flag = force->numeric(FLERR, arg[iarg+1]);
if (gco2_flag != 0 && gco2_flag != 1)
error->all(FLERR, "Illegal fix kinetics/growth/monod command: gco2_flag");
iarg += 2;
} else
error->all(FLERR, "Illegal fix kinetics/growth/monod command");
}
}
/* ---------------------------------------------------------------------- */
FixKineticsMonod::~FixKineticsMonod() {
memory->destroy(species);
memory->destroy(growrate);
}
/* ---------------------------------------------------------------------- */
int FixKineticsMonod::setmask() {
int mask = 0;
mask |= PRE_FORCE;
return mask;
}
/* ---------------------------------------------------------------------- */
void FixKineticsMonod::init() {
if (!atom->radius_flag)
error->all(FLERR, "Fix requires atom attribute diameter");
// register fix kinetics with this class
kinetics = NULL;
int nfix = modify->nfix;
for (int j = 0; j < nfix; j++) {
if (strcmp(modify->fix[j]->style, "kinetics") == 0) {
kinetics = static_cast<FixKinetics *>(lmp->modify->fix[j]);
break;
}
}
if (kinetics == NULL)
lmp->error->all(FLERR, "fix kinetics command is required for running IbM simulation");
bio = kinetics->bio;
if (bio->nnu == 0)
error->all(FLERR, "fix_kinetics/monod requires Nutrients input");
else if (bio->maintain == NULL)
error->all(FLERR, "fix_kinetics/monod requires Maintenance input");
else if (bio->decay == NULL)
error->all(FLERR, "fix_kinetics/monod requires Decay input");
else if (bio->ks == NULL)
error->all(FLERR, "fix_kinetics/monod requires Ks input");
else if (bio->yield == NULL)
error->all(FLERR, "fix_kinetics/monod requires Yield input");
else if (bio->mu == NULL)
error->all(FLERR, "fix_kinetics/monod requires Growth Rate input");
nx = kinetics->nx;
ny = kinetics->ny;
nz = kinetics->nz;
if (species == NULL) {
species = memory->create(species, atom->ntypes+1, "monod:species");
growrate = memory->create(growrate, atom->ntypes+1, 2, kinetics->ngrids, "monod:growrate");
}
//Get computational domain size
if (domain->triclinic == 0) {
xlo = domain->boxlo[0];
xhi = domain->boxhi[0];
ylo = domain->boxlo[1];
yhi = domain->boxhi[1];
zlo = domain->boxlo[2];
zhi = domain->boxhi[2];
} else {
xlo = domain->boxlo_bound[0];
xhi = domain->boxhi_bound[0];
ylo = domain->boxlo_bound[1];
yhi = domain->boxhi_bound[1];
zlo = domain->boxlo_bound[2];
zhi = domain->boxhi_bound[2];
}
stepx = (xhi - xlo) / nx;
stepy = (yhi - ylo) / ny;
stepz = (zhi - zlo) / nz;
vol = stepx * stepy * stepz;
init_param();
}
/* ----------------------------------------------------------------------
initialize parameters for monod growth
------------------------------------------------------------------------- */
void FixKineticsMonod::init_param() {
mu = bio->mu;
decay = bio->decay;
maintain = bio->maintain;
yield = bio->yield;
ks = bio->ks;
ntypes = atom->ntypes;
isub = 0; io2 = 0; inh4 = 0; ino2 = 0; ino3 = 0; isuc = 0; ico2 = 0; igco2 = 0;
// initialize nutrients
for (int nu = 1; nu <= bio->nnu; nu++) {
if (strcmp(bio->nuname[nu], "sub") == 0)
isub = nu;
else if (strcmp(bio->nuname[nu], "o2") == 0)
io2 = nu;
else if (strcmp(bio->nuname[nu], "nh4") == 0)
inh4 = nu;
else if (strcmp(bio->nuname[nu], "no2") == 0)
ino2 = nu;
else if (strcmp(bio->nuname[nu], "no3") == 0)
ino3 = nu;
else if (strcmp(bio->nuname[nu], "suc") == 0)
isuc = nu;
else if (strcmp(bio->nuname[nu], "co2") == 0)
ico2 = nu;
else if (strcmp(bio->nuname[nu], "gco2") == 0)
igco2 = nu;
}
// initialize species
for (int i = 1; i <= ntypes; i++) {
// take the first three chars from type name;
char *name = new char[4];
strncpy(name, bio->tname[i], 3);
name[3] = 0;
if (strcmp(name, "het") == 0 || strcmp(name, "HET") == 0) {
species[i] = HET;
if (isub == 0) error->all(FLERR, "het growth requires nutrient 'sub' (substrate) defined in Nutrients section");
if (io2 == 0) error->all(FLERR, "het growth requires nutrient 'o2' defined in Nutrients section");
if (eta_het > 0) {
if (ino2 == 0) error->all(FLERR, "het anaerobic growth requires nutrient 'no2' defined in Nutrients section");
if (ino3 == 0) error->all(FLERR, "het anaerobic growth requires nutrient 'no3' defined in Nutrients section");
}
} else if (strcmp(name, "aob") == 0 || strcmp(name, "AOB") == 0) {
species[i] = AOB;
if (inh4 == 0) error->all(FLERR, "aob growth requires nutrient 'nh4' defined in Nutrients section");
if (ino2 == 0) error->all(FLERR, "aob growth requires nutrient 'no2' defined in Nutrients section");
if (io2 == 0) error->all(FLERR, "aob growth requires nutrient 'o2' defined in Nutrients section");
} else if (strcmp(name, "nob") == 0 || strcmp(name, "NOB") == 0) {
species[i] = NOB;
if (ino2 == 0) error->all(FLERR, "nob growth
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
nufeb_tools-0.0.52.tar.gz (76个子文件)
nufeb_tools-0.0.52
PKG-INFO 2KB
README.rst 1KB
.readthedocs.yml 461B
.coveragerc 594B
pyproject.toml 311B
docs
conf.py 10KB
datafed.rst 478B
changelog.rst 43B
analysis.rst 3KB
license.rst 67B
authors.rst 41B
requirements.txt 415B
readme.rst 39B
examples.rst 38B
Makefile 1KB
atom_generation.rst 254B
index.rst 338B
_static
images
Colonies_over_time.png 119KB
growth_rate_div.png 41KB
total_biomass_vs_time.png 19KB
biomass_vs_time.png 21KB
growth_rate_time.png 63KB
testcolony.png 67KB
average_nutrients.png 17KB
.gitignore 18B
profiling test.py 883B
profiling_mother.prof 124KB
AUTHORS.rst 82B
data
runs.tar 79.3MB
profiling.prof 161KB
.github
workflows
python-publish.yml 2KB
Test.yml 1KB
tests
test_utils.py 405B
test_atom_gen.py 251B
conftest.py 279B
test_plotting.py 635B
tox.ini 2KB
src
nufeb_tools.egg-info
PKG-INFO 2KB
requires.txt 198B
not-zip-safe 1B
SOURCES.txt 2KB
entry_points.txt 240B
top_level.txt 12B
dependency_links.txt 1B
nufeb_tools
playbook.yml 2KB
generate_atom_dev.py 23KB
maketestplots.py 1KB
generate_atom.py 17KB
storage.py 2KB
utils.py 24KB
templates
bacillus.txt 3KB
fix_bio_kinetics_monod.txt 21KB
slurm.txt 1KB
__init__.py 0B
inputscript.txt 2KB
slurm_dev.txt 1KB
local.txt 1KB
whole_culture_growth_curves.py 2KB
parameter_optimization.py 4KB
__init__.py 577B
spatial.py 5KB
plot.py 13KB
setup.cfg 2KB
setup.py 708B
.gitignore 567B
CHANGELOG.rst 128B
notebooks
cell ancestry.ipynb 517KB
metadata.json 0B
dask testing.ipynb 12KB
neighbor.ipynb 440KB
Colonies over time.png 119KB
neighbor-fitness.ipynb 527KB
cell ancestry - Copy.ipynb 227KB
dasktest.py 2KB
profiling test mother_cells.py 2KB
LICENSE.txt 1KB
共 76 条
- 1
资源评论
- 韩翔宇2023-05-30资源内容详细全面,与描述一致,对我很有用,有一定的使用价值。
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功