完成液面深度计算

This commit is contained in:
liaodeyun 2025-12-04 15:21:31 +08:00 committed by 廖德云
parent 2a6915b894
commit 37588688b8
7 changed files with 110 additions and 33 deletions

View File

@ -10,7 +10,7 @@ spring:
datasource:
# 主库数据源
MASTER:
url: jdbc:mysql://192.168.3.246/ruoyi-geek?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
url: jdbc:mysql://ngtools.cn:3306/ruoyi-geek?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
# url: jdbc:mariadb://192.168.3.154:3306/ruoyi-geek?useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: root
password: 4877017Ldy.

View File

@ -3,7 +3,7 @@ spring:
# redis 配置
redis:
# 地址
host: 192.168.3.246
host: localhost
# 端口默认为6379
port: 6379
# 数据库索引

View File

@ -10,7 +10,7 @@ public class FormatUtil {
private static final DecimalFormat df4 = new DecimalFormat("#0.0000");
private static final DecimalFormat df5 = new DecimalFormat("#0.00000");
public static double format(double value, Optional<Integer> weishu ) {
public static double format(double value, Optional<Integer> weishu) {
double result;
Integer weishudefault=weishu.orElse(4);

View File

@ -123,26 +123,14 @@ public class GasController {
public static double Crit(GasProps gasProps, double dPlenumVelocity)
{
thermService = new ThermService();
detailService = new DetailService();
gbt11062Service = new GBT11062Service();
//variables local to function
double DH, DDH, S, H;
double tolerance = 1.0;
double R, P, T, Z;
int i;
//check objects for readiness; try to initialize if not
if (null == detailService || null == thermService)
{
NG_Cal_UnInit();
if (GasConstants.NG_Cal_INITIALIZED != NG_Cal_Init())
{
gasProps.lStatus =GasConstants. MEMORY_ALLOCATION_ERROR; return 0.0;
}
}
//begin by calculating densities and thermodynamic properties
thermService.Run(gasProps, detailService);

View File

@ -9,6 +9,7 @@ import com.ruoyi.caltools.service.GBT11062Service;
import com.ruoyi.caltools.service.ThermService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.controller.UnitConvert;
import org.apache.juli.logging.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static com.ruoyi.caltools.controller.GasController.Crit;
@ -160,7 +162,7 @@ public class WaterDeepCalController {
/**
* 计算给定深度的理论传播时间
*/
private Double calculateTheoreticalTime(Double depth, WaterDeepCalParams request) {
private Double calculateTheoreticalTime(Double depth, WaterDeepCalParams request,WaterDeepCalResult response) {
if (depth <= 0) return 0.0;
int segments = Math.max(50, (int)(depth / 10)); // 根据深度调整分段数
@ -172,6 +174,8 @@ public class WaterDeepCalController {
// 克隆GasProps以避免修改原始对象
GasProps tempGasProps = cloneGasProps(request.getGasProps());
List<String> tempSegmentsData=new ArrayList<>();
for (int i = 0; i < segments; i++) {
Double currentDepth = i * dz + dz/2; // 中点
@ -180,9 +184,10 @@ public class WaterDeepCalController {
request.getTemperatureGradient(), request.getConstantLayerDepth());
// 计算中点压力
Double pressure = pressureAtDepth(currentDepth, request.getSurfacePressure(),
request.getSurfaceTemperature(), request.getTemperatureGradient(),
request.getConstantLayerDepth(), tempGasProps);
// Double pressure = pressureAtDepth(currentDepth, request.getSurfacePressure(),
// request.getSurfaceTemperature(), request.getTemperatureGradient(),
// request.getConstantLayerDepth(), tempGasProps);
Double pressure = request.getSurfacePressure();
// 设置气体参数
tempGasProps.dTf = temp;
@ -191,15 +196,17 @@ public class WaterDeepCalController {
// 计算声速
Crit(tempGasProps, 0);
Double soundVelocity = tempGasProps.dSOS;
// 检查声速有效性
if (soundVelocity <= 0 || Double.isNaN(soundVelocity)) {
soundVelocity = 300.0; // 默认声速
}
totalTime += dz / soundVelocity;
String tempStr= ( "总段数:"+segments+",段序号:"+ Integer.toString(i + 1)+",段长度:"+ FormatUtil.format(dz, Optional.of(2))+",该段声速:"+ FormatUtil.format(tempGasProps.dSOS,Optional.of(2))+",该段时间"+FormatUtil.format(dz/soundVelocity,Optional.of(2))+",该段温度:"+FormatUtil.format(temp-273.15,Optional.of(2))+",总深度:"+FormatUtil.format( currentDepth,Optional.of(2))+",总时间:"+FormatUtil.format(totalTime,Optional.of(2))+"\n");
tempSegmentsData.add(tempStr);
// System.out.printf(tempStr);
}
response.setDataSegment(tempSegmentsData);
return 2 * totalTime; // 往返时间
}
@ -250,9 +257,8 @@ public class WaterDeepCalController {
// 二分法迭代
while (iterations < request.getMaxIterations()) {
iterationHistory.add(currentDepth);
// 计算理论时间
Double theoreticalTime = calculateTheoreticalTime(currentDepth, request);
Double theoreticalTime = calculateTheoreticalTime(currentDepth, request,response);
Double error = theoreticalTime - request.getMeasuredTime();
// 检查收敛
@ -296,6 +302,7 @@ public class WaterDeepCalController {
response.setCorrectionFactor(correctionFactor);
response.setIterations(iterations);
response.setIterationHistory(iterationHistory);
response.setInitialSOS(surfaceSoundVelocity);
if (iterations < request.getMaxIterations()) {
response.setStatus("CONVERGED");

View File

@ -30,9 +30,29 @@ public class WaterDeepCalResult {
}
public Double initialEstimate; // 初始估计深度(m)
public Double getInitialSOS() {
return initialSOS;
}
public void setInitialSOS(Double initialSOS) {
this.initialSOS = initialSOS;
}
public Double initialSOS; // 初始声速
public Double correctionFactor; // 修正因子
public Integer iterations; // 迭代次数
public String status; // 计算状态
public List<Double> iterationHistory; // 迭代历史
public List<String> getDataSegment() {
return dataSegment;
}
public void setDataSegment(List<String> dataSegment) {
this.dataSegment = dataSegment;
}
public List<String> dataSegment; // 分段数据
}

72
ry.sh
View File

@ -1,10 +1,16 @@
#!/bin/sh
# ./ry.sh start 启动 stop 停止 restart 重启 status 状态
# 定义JAR包所在目录
APP_HOME=/home/yjly/www/API/ruoyi
AppName=ruoyi-admin.jar
# JAR包完整路径
JAR_PATH=$APP_HOME/$AppName
# JVM参数
JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"
APP_HOME=`pwd`
# 日志文件路径
LOG_PATH=$APP_HOME/logs/$AppName.log
if [ "$1" = "" ];
@ -13,9 +19,10 @@ then
exit 1
fi
if [ "$AppName" = "" ];
# 检查JAR包是否存在
if [ ! -f "$JAR_PATH" ];
then
echo -e "\033[0;31m 未输入应用名 \033[0m"
echo -e "\033[0;31m 应用JAR包不存在: $JAR_PATH \033[0m"
exit 1
fi
@ -26,8 +33,17 @@ function start()
if [ x"$PID" != x"" ]; then
echo "$AppName is running..."
else
nohup java $JVM_OPTS -jar $AppName > /dev/null 2>&1 &
# 进入应用目录
cd $APP_HOME
# 创建logs目录如果不存在
if [ ! -d "$APP_HOME/logs" ]; then
mkdir -p $APP_HOME/logs
fi
nohup java $JVM_OPTS -jar $JAR_PATH > /dev/null 2>&1 &
echo "Start $AppName success..."
# 显示启动日志
sleep 2
echo "查看启动日志: tail -f $LOG_PATH"
fi
}
@ -67,11 +83,49 @@ function status()
PID=`ps -ef |grep java|grep $AppName|grep -v grep|wc -l`
if [ $PID != 0 ];then
echo "$AppName is running..."
# 显示运行进程详情
ps -ef |grep java|grep $AppName|grep -v grep
else
echo "$AppName is not running..."
fi
}
# 新增查看日志函数
function log()
{
if [ ! -f "$LOG_PATH" ]; then
echo "日志文件不存在: $LOG_PATH"
else
tail -f $LOG_PATH
fi
}
# 新增查看端口函数
function port()
{
PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'`
if [ x"$PID" != x"" ]; then
echo "应用进程ID: $PID"
# 获取端口号
netstat -tlnp 2>/dev/null | grep $PID
else
echo "$AppName 未运行"
fi
}
# 新增备份函数
function backup()
{
DATE=`date +%Y%m%d%H%M%S`
BACKUP_DIR="$APP_HOME/backup"
if [ ! -d "$BACKUP_DIR" ]; then
mkdir -p $BACKUP_DIR
fi
BACKUP_FILE="$BACKUP_DIR/$AppName.$DATE"
cp $JAR_PATH $BACKUP_FILE
echo "已备份到: $BACKUP_FILE"
}
case $1 in
start)
start;;
@ -81,6 +135,14 @@ case $1 in
restart;;
status)
status;;
log)
log;;
port)
port;;
backup)
backup;;
*)
echo -e "\033[0;31m 无效的操作名 \033[0m"
echo "用法: $0 {start|stop|restart|status|log|port|backup}"
exit 1
esac