diff --git a/pygrt/C_extension/include/grt/common/model.h b/pygrt/C_extension/include/grt/common/model.h index 537fd18..2b16abf 100755 --- a/pygrt/C_extension/include/grt/common/model.h +++ b/pygrt/C_extension/include/grt/common/model.h @@ -23,6 +23,7 @@ typedef struct { size_t ircv; ///< 接收点所在虚拟层位, ircv>=1, ircv != isrc bool ircvup; ///< 接收点位于浅层, ircv < isrc bool io_depth; ///< 读取的模型首列为每层顶界面深度 + bool srcrcv_isInserted; ///< 震源和台站是否已经以虚拟层的形式插入 cplx_t omgref; ///< 参考圆频率, 用于计算衰减 cplx_t omega; ///< 圆频率 diff --git a/pygrt/C_extension/src/common/model.c b/pygrt/C_extension/src/common/model.c index e80983d..043a897 100755 --- a/pygrt/C_extension/src/common/model.c +++ b/pygrt/C_extension/src/common/model.c @@ -189,7 +189,7 @@ void grt_mod1d_xa_xb(GRT_MODEL1D *mod1d, const real_t k) size_t ircv = mod1d->ircv; for(size_t i=0; in; ++i){ - if( i == isrc || i == ircv ){ + if( mod1d->srcrcv_isInserted && (i == isrc || i == ircv) ){ mod1d->xa[i] = mod1d->xa[i-1]; mod1d->caca[i] = mod1d->caca[i-1]; mod1d->xb[i] = mod1d->xb[i-1]; @@ -230,6 +230,10 @@ void grt_realloc_mod1d(GRT_MODEL1D *mod1d, size_t n){ GRT_MODEL1D * grt_read_mod1d_from_file(const char *modelpath, real_t depsrc, real_t deprcv, bool allowLiquid){ GRTCheckFileExist(modelpath); + + if(depsrc * deprcv < 0.0){ + GRTRaiseError("depsrc and deprcv should have the same sign."); + } FILE *fp = GRTCheckOpenFile(modelpath, "r"); @@ -390,6 +394,7 @@ GRT_MODEL1D * grt_read_mod1d_from_file(const char *modelpath, real_t depsrc, rea mod1d->n = nlay; mod1d->depsrc = depsrc; mod1d->deprcv = deprcv; + mod1d->srcrcv_isInserted = (depsrc >= 0.0 && deprcv >= 0.0)? true : false; // 记录每层是否为液体层 for(size_t i = 0; i < mod1d->n; ++i){ diff --git a/pygrt/c_structures.py b/pygrt/c_structures.py index cdabad4..bda9965 100755 --- a/pygrt/c_structures.py +++ b/pygrt/c_structures.py @@ -96,6 +96,7 @@ class c_GRT_MODEL1D(Structure): ('ircv', c_size_t), ('ircvup', c_bool), ('io_depth', c_bool), + ('srcrcv_isInserted', c_bool), ('omgref', CPLX), ('omega', CPLX),