From 8fc5f076321937988917d2696424d5a92b3cccdb Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Thu, 26 Jun 2025 13:11:20 +0800 Subject: [PATCH] FIX: raise error if receiver located on the interface where liquid exist --- pygrt/C_extension/src/common/model.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pygrt/C_extension/src/common/model.c b/pygrt/C_extension/src/common/model.c index 1a0aec9b..16c4a868 100755 --- a/pygrt/C_extension/src/common/model.c +++ b/pygrt/C_extension/src/common/model.c @@ -308,8 +308,13 @@ PYMODEL1D * read_pymod_from_file(const char *command, const char *modelpath, dou return NULL; } - if(!allowLiquid && vb <=0){ - fprintf(stderr, "[%s] " BOLD_RED "In model file, line %d, nonpositive Vs is not supported.\n" DEFAULT_RESTORE, command, iline); + if(vb < 0.0){ + fprintf(stderr, "[%s] " BOLD_RED "In model file, line %d, negative Vs is not supported.\n" DEFAULT_RESTORE, command, iline); + return NULL; + } + + if(!allowLiquid && vb == 0.0){ + fprintf(stderr, "[%s] " BOLD_RED "In model file, line %d, Vs==0.0 is not supported.\n" DEFAULT_RESTORE, command, iline); return NULL; } @@ -392,6 +397,17 @@ PYMODEL1D * read_pymod_from_file(const char *command, const char *modelpath, dou pymod->depsrc = depsrc; pymod->deprcv = deprcv; + // 检查,接收点不能位于液-液、固-液界面 + if(isrc < nlay-1 && pymod->Thk[ircv] == 0.0 && pymod->Vb[ircv]*pymod->Vb[ircv+1] == 0.0){ + fprintf(stderr, + "[%s] " BOLD_RED "The receiver is located on the interface where there is liquid on one side. " + "Due to the discontinuity of the tangential displacement on this interface, " + "to reduce ambiguity, it is recommended that you add a small offset to the receiver depth, " + "thereby explicitly placing the receiver within a specific layer. \n" + DEFAULT_RESTORE, command); + return NULL; + } + fclose(fp); free(modarr);