完成液面深度计算
This commit is contained in:
parent
2a6915b894
commit
f0afd22cdd
@ -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/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.
|
||||
|
||||
@ -3,7 +3,7 @@ spring:
|
||||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
host: 192.168.3.246
|
||||
host: localhost
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -123,27 +123,15 @@ 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
|
||||
//begin by calculating densities and thermodynamic properties
|
||||
thermService.Run(gasProps, detailService);
|
||||
|
||||
//DH is enthalpy change from plenum to throat; this is our initial guess
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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; // 分段数据
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user