添加一年的SSL证书
This commit is contained in:
commit
cf901b1bbd
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
BIN
out/artifacts/ngtools_jar/ngtools.jar
Normal file
BIN
out/artifacts/ngtools_jar/ngtools.jar
Normal file
Binary file not shown.
87
pom.xml
Normal file
87
pom.xml
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.ng</groupId>
|
||||
<artifactId>ngtools</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>ng</name>
|
||||
<description>ng</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.6.13</spring-boot.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.13</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.ng.ngtools.NgApplication</mainClass>
|
||||
<!-- <skip>true</skip>-->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
3
src/META-INF/MANIFEST.MF
Normal file
3
src/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: com.ng.ngtools.NgApplication
|
||||
|
71
src/main/java/com/ng/ngtools/NgApplication.java
Normal file
71
src/main/java/com/ng/ngtools/NgApplication.java
Normal file
@ -0,0 +1,71 @@
|
||||
package com.ng.ngtools;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@SpringBootApplication(scanBasePackages="com.ng.ngtools.modules")
|
||||
@ComponentScan(basePackages = {"com.ng.ngtools.tangible","com.ng.ngtools.Tools"})
|
||||
@EnableScheduling
|
||||
@EnableAsync
|
||||
@EnableCaching
|
||||
public class NgApplication {
|
||||
|
||||
public final static Logger log = LoggerFactory.getLogger(NgApplication.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext application = SpringApplication.run(NgApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = null; String httpsport ="";
|
||||
String httpport ="";
|
||||
try {
|
||||
ip = InetAddress.getLocalHost().getHostAddress();
|
||||
httpsport= env.getProperty("server.port");
|
||||
httpport= env.getProperty("myhttp-port");
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
|
||||
}
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"程序启动成功! URLs:\n\t" +
|
||||
"http: \t\thttp://"+ip+":" + httpport +"\n\t" +
|
||||
"https: \t\thttps://"+ip +":"+ httpsport +"\n\t" +
|
||||
"\n----------------------------------------------------------\n\t"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Value("${myhttp-port}")
|
||||
private Integer httpPort;
|
||||
/*SpringBoot 2.x版本(以及更高版本)使用下面的代码*/
|
||||
@Bean
|
||||
public ServletWebServerFactory servletcontainer(){
|
||||
TomcatServletWebServerFactory tomcat =new TomcatServletWebServerFactory();
|
||||
tomcat.addAdditionalTomcatConnectors(createHTTPConnector());
|
||||
return tomcat;
|
||||
}
|
||||
private Connector createHTTPConnector(){
|
||||
Connector connector =new Connector("org.apache.coyote.http11.Http11NioProtocol");
|
||||
connector.setScheme("http");
|
||||
connector.setSecure(false);
|
||||
connector.setPort(httpPort);
|
||||
return connector;
|
||||
}
|
||||
|
||||
|
||||
}
|
1356
src/main/java/com/ng/ngtools/Tools/NG_Cal.java
Normal file
1356
src/main/java/com/ng/ngtools/Tools/NG_Cal.java
Normal file
File diff suppressed because it is too large
Load Diff
45
src/main/java/com/ng/ngtools/Tools/testAPI.java
Normal file
45
src/main/java/com/ng/ngtools/Tools/testAPI.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.ng.ngtools.Tools;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
/*
|
||||
* API支持HTTPS/HTTP测试*
|
||||
*
|
||||
* @author JustryDeng
|
||||
* @DATE 2018年9月13日上午8:36:29
|
||||
*/
|
||||
@RestController
|
||||
public class testAPI {
|
||||
/*
|
||||
*HTTP/HTTPS发送get请求
|
||||
*
|
||||
*@DATE 2018年9月13日上午10:21:07*/
|
||||
@GetMapping("/get")
|
||||
public String testMethodGet(HttpServletRequest request) {//获取URL协议
|
||||
String requestURL = request.getRequestURL().toString();
|
||||
String protocol = requestURL.split("://")[0];//获取当前URL连接中的端口
|
||||
Integer port = request.getServerPort();
|
||||
return "get --->" + protocol + "\t" + port;
|
||||
}
|
||||
|
||||
//HTTP/HTTPS发送post请求
|
||||
//@DATE 2018年9月13日上午10:21:43
|
||||
|
||||
@PostMapping("/post")
|
||||
public String testMethodPost(HttpServletRequest request,@RequestBody String bodystring){
|
||||
//获取URL协议
|
||||
String requestURL =request.getRequestURL().toString();
|
||||
String protocol =requestURL.split("://")[0];
|
||||
//获取当前URL连接中的端口
|
||||
Integer port =request.getServerPort();
|
||||
return "post --->"+protocol +"\t"+port +"\n"+bodystring;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
103
src/main/java/com/ng/ngtools/common/Result.java
Normal file
103
src/main/java/com/ng/ngtools/common/Result.java
Normal file
@ -0,0 +1,103 @@
|
||||
package com.ng.ngtools.common;
|
||||
|
||||
import com.ng.ngtools.common.constant.CommonConstant;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel(value="接口返回对象", description="接口返回对象")
|
||||
public class Result<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成功标志
|
||||
*/
|
||||
@ApiModelProperty(value = "成功标志")
|
||||
private boolean success = true;
|
||||
|
||||
/**
|
||||
* 返回处理消息
|
||||
*/
|
||||
@ApiModelProperty(value = "返回处理消息")
|
||||
private String message = "操作成功!";
|
||||
|
||||
/**
|
||||
* 返回代码
|
||||
*/
|
||||
@ApiModelProperty(value = "返回代码")
|
||||
private Integer code = 0;
|
||||
|
||||
/**
|
||||
* 返回数据对象 data
|
||||
*/
|
||||
@ApiModelProperty(value = "返回数据对象")
|
||||
private T result;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
@ApiModelProperty(value = "时间戳")
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
public Result() {
|
||||
|
||||
}
|
||||
public Result<T> success(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_OK_200;
|
||||
this.success = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public static Result<Object> ok() {
|
||||
Result<Object> r = new Result<Object>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setMessage("成功");
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result<String> ok(String msg) {
|
||||
Result<String> r = new Result<String>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setResult(msg);
|
||||
r.setMessage(msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result<Object> ok(Object data) {
|
||||
Result<Object> r = new Result<Object>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConstant.SC_OK_200);
|
||||
r.setResult(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Result<Object> error(String msg) {
|
||||
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
|
||||
}
|
||||
|
||||
public static Result<Object> error(int code, String msg) {
|
||||
Result<Object> r = new Result<Object>();
|
||||
r.setCode(code);
|
||||
r.setMessage(msg);
|
||||
r.setSuccess(false);
|
||||
return r;
|
||||
}
|
||||
|
||||
public Result<T> error500(String message) {
|
||||
this.message = message;
|
||||
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
||||
this.success = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.ng.ngtools.common.constant;
|
||||
|
||||
public interface CommonConstant {
|
||||
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
|
||||
Integer SC_OK_200 = 200;
|
||||
/** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */
|
||||
Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
|
||||
}
|
67
src/main/java/com/ng/ngtools/demos/web/BasicController.java
Normal file
67
src/main/java/com/ng/ngtools/demos/web/BasicController.java
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.ng.ngtools.demos.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
|
||||
*/
|
||||
@Controller
|
||||
public class BasicController {
|
||||
|
||||
// http://127.0.0.1:8080/hello?name=lisi
|
||||
@RequestMapping("/hello")
|
||||
@ResponseBody
|
||||
public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) {
|
||||
return "Hello " + name;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/user
|
||||
@RequestMapping("/user")
|
||||
@ResponseBody
|
||||
public User user() {
|
||||
User user = new User();
|
||||
user.setName("theonefx");
|
||||
user.setAge(666);
|
||||
return user;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/save_user?name=newName&age=11
|
||||
@RequestMapping("/save_user")
|
||||
@ResponseBody
|
||||
public String saveUser(User u) {
|
||||
return "user will save: name=" + u.getName() + ", age=" + u.getAge();
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/html
|
||||
@RequestMapping("/html")
|
||||
public String html(){
|
||||
return "index.html";
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public void parseUser(@RequestParam(name = "name", defaultValue = "unknown user") String name
|
||||
, @RequestParam(name = "age", defaultValue = "12") Integer age, User user) {
|
||||
user.setName("zhangsan");
|
||||
user.setAge(18);
|
||||
}
|
||||
}
|
1546
src/main/java/com/ng/ngtools/modules/Detail.java
Normal file
1546
src/main/java/com/ng/ngtools/modules/Detail.java
Normal file
File diff suppressed because it is too large
Load Diff
1784
src/main/java/com/ng/ngtools/modules/FlowCal.java
Normal file
1784
src/main/java/com/ng/ngtools/modules/FlowCal.java
Normal file
File diff suppressed because it is too large
Load Diff
167
src/main/java/com/ng/ngtools/modules/GB11062.java
Normal file
167
src/main/java/com/ng/ngtools/modules/GB11062.java
Normal file
@ -0,0 +1,167 @@
|
||||
package com.ng.ngtools.modules;
|
||||
|
||||
public class GB11062
|
||||
{
|
||||
|
||||
private int iNCC; // number of components
|
||||
private final int[] aiCID = new int[21]; // component IDs
|
||||
private final double[] dXi = new double[21]; // mole fraction of component i
|
||||
private final Detail ptDetail;
|
||||
public GB11062()
|
||||
{
|
||||
|
||||
ptDetail = new Detail();
|
||||
for (int i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
dXi[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
} // Detail()
|
||||
public final void Run(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
int i;
|
||||
// Check for gas composition change
|
||||
ptAGA10.argValue.bForceUpdate = (ptAGA10.argValue.bForceUpdate || ptDetail.compositionchange(ptAGA10));
|
||||
// assign component IDs and values
|
||||
if (ptAGA10.argValue.bForceUpdate)
|
||||
{
|
||||
iNCC = -1;
|
||||
for (i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
if (ptAGA10.argValue.adMixture[i] > 0.0)
|
||||
{
|
||||
iNCC = iNCC + 1;
|
||||
aiCID[iNCC] = i;
|
||||
dXi[iNCC] = ptAGA10.argValue.adMixture[i];
|
||||
}
|
||||
}
|
||||
iNCC = iNCC + 1;
|
||||
//calculate composition dependent quantities; ported from original
|
||||
//FORTRAN functions paramdl() and chardl()
|
||||
GasPropsCal(ptAGA10);
|
||||
}
|
||||
}
|
||||
|
||||
private void GasPropsCal(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
double[] adTableMri = new double[] {16.0430, 28.0135, 44.0100, 30.0700, 44.0970, 18.0153, 34.0820, 2.0159, 28.0100, 31.9988, 58.1230, 58.1230, 72.1500, 72.1500, 86.1770, 100.2040, 114.2310, 128.2580, 142.2850, 4.0026, 39.9480};
|
||||
double[] adTablePc = new double[] {4.604, 3.399, 7.382, 4.88, 4.249, 22.118, 9.005, 1.297, 3.499, 5.081, 3.648, 3.797, 3.381, 3.369, 3.012, 2.736, 2.486, 0, 0, 0.2275, 4.876};
|
||||
double[] adTableTc = new double[] {190.55, 126.1, 304.19, 305.43, 369.82, 647.3, 373.5, 33.2, 132.92, 154.7, 408.13, 425.16, 460.39, 469.6, 507.4, 540.2, 568.76, 0, 0, 5.2, 150.82};
|
||||
double[] adTableBzsx = new double[] {15, 0, 0, 13, 9.5, 0, 45.5, 74.2, 74.2, 0, 8.4, 8.4, 8.3, 8.3, 7.7, 7.0, 0, 0, 0, 0, 0};
|
||||
double[] adTableBzxx = new double[] {5.0, 0, 0, 2.9, 2.1, 0, 4.3, 4.0, 12.5, 0, 1.8, 1.8, 1.4, 1.4, 1.2, 1.0, 0.96, 0, 0, 0, 0};
|
||||
double[][] adTableZn = new double[][]
|
||||
{
|
||||
{0.9976, 0.9995, 0.9933, 0.99, 0.9789, 0.93, 0.99, 1.0006, 0.9993, 0.999, 0.958, 0.9572, 0.9377, 0.918, 0.892, 0.83, 0.742, 0.613, 0.434, 1.0005, 0.999},
|
||||
{0.998, 0.9997, 0.9944, 0.9915, 0.9821, 0.945, 0.99, 1.0006, 0.9995, 0.9992, 0.968, 0.965, 0.948, 0.937, 0.913, 0.866, 0.802, 0.71, 0.584, 1.0005, 0.9992},
|
||||
{0.9981, 0.9997, 0.9944, 0.992, 0.9834, 0.952, 0.99, 1.0006, 0.9996, 0.9993, 0.971, 0.9682, 0.953, 0.945, 0.919, 0.876, 0.817, 0.735, 0.623, 1.0005, 0.9993}
|
||||
};
|
||||
double[][] adTableSqrtbj = new double[][]
|
||||
{
|
||||
{0.049, 0.0224, 0.0819, 0.1, 0.1453, 0.2646, 0.1, -0.004, 0.0265, 0.0316, 0.2049, 0.2069, 0.251, 0.2864, 0.3286, 0.4123, 0.5079, 0.6221, 0.7523, 0.0006, 0.0316},
|
||||
{0.0447, 0.0173, 0.0748, 0.0922, 0.1338, 0.2345, 0.1, -0.0048, 0.0224, 0.0283, 0.1789, 0.1871, 0.228, 0.251, 0.295, 0.3661, 0.445, 0.5385, 0.645, 0.0002, 0.0283},
|
||||
{0.0436, 0.0173, 0.0728, 0.0894, 0.1288, 0.2191, 0.1, -0.0051, 0.02, 0.0265, 0.1703, 0.1783, 0.2168, 0.2345, 0.2846, 0.3521, 0.4278, 0.5148, 0.614, 0, 0.0265}
|
||||
};
|
||||
double[][] adTableHhvMol = new double[][]
|
||||
{
|
||||
{892.97, 0, 0, 1564.34, 2224.01, 45.074, 562.94, 286.63, 282.8, 0, 2874.2, 2883.82, 3535.98, 3542.89, 4203.23, 4862.87, 5522.4, 6182.91, 6842.69, 0, 0},
|
||||
{891.56, 0, 0, 1562.14, 2221.1, 44.433, 562.38, 286.15, 282.91, 0, 2870.58, 2879.76, 3531.68, 3538.6, 4198.24, 4857.18, 5516.01, 6175.82, 6834.9, 0, 0},
|
||||
{891.09, 0, 0, 1561.41, 2220.13, 44.224, 562.19, 285.99, 282.95, 0, 2869.38, 2878.57, 3530.24, 3537.17, 4196.58, 4855.29, 5513.88, 6173.46, 6832.31, 0, 0},
|
||||
{890.63, 0, 0, 1560.69, 2219.17, 44.016, 562.01, 285.83, 282.98, 0, 2868.2, 2877.4, 3528.83, 3535.77, 4194.95, 4853.43, 5511.8, 6171.15, 6829.77, 0, 0}
|
||||
};
|
||||
double[][] adTableLhvMol = new double[][]
|
||||
{
|
||||
{802.82, 0, 0, 1429.12, 2043.71, 0, 517.87, 241.56, 282.8, 0, 2648.83, 2658.45, 3265.54, 3272.45, 3887.71, 4502.28, 5116.73, 5732.17, 6346.88, 0, 0},
|
||||
{802.69, 0, 0, 1428.84, 2043.37, 0, 517.95, 241.72, 282.91, 0, 2648.42, 2657.6, 3265.08, 3272, 3887.21, 4501.72, 5116.11, 5731.49, 6346.14, 0, 0},
|
||||
{802.65, 0, 0, 1428.74, 2043.23, 0, 517.97, 241.76, 282.95, 0, 2648.26, 2657.45, 3264.89, 3271.83, 3887.01, 4501.49, 5115.87, 5731.22, 6345.85, 0, 0},
|
||||
{802.6, 0, 0, 1428.64, 2043.11, 0, 517.99, 241.81, 282.98, 0, 2648.12, 2657.32, 3264.73, 3271.67, 3886.84, 4501.3, 5115.66, 5730.99, 6345.59, 0, 0}
|
||||
};
|
||||
|
||||
int i;
|
||||
|
||||
double dMair = 28.9626;
|
||||
double dZair = 0;
|
||||
|
||||
for (i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
if (ptAGA10.argValue.adMixture[i] != 0)
|
||||
{
|
||||
ptAGA10.argValue.Pc += adTablePc[i] * ptAGA10.argValue.adMixture[i];
|
||||
ptAGA10.argValue.TC += adTableTc[i] * ptAGA10.argValue.adMixture[i];
|
||||
if (adTableBzsx[i] != 0)
|
||||
{
|
||||
ptAGA10.argValue.Bzsx += ptAGA10.argValue.adMixture[i] / adTableBzsx[i];
|
||||
ptAGA10.argValue.Bzxx += ptAGA10.argValue.adMixture[i] / adTableBzxx[i];
|
||||
}
|
||||
|
||||
if (i >= 10 & i <= 18)
|
||||
{
|
||||
ptAGA10.argValue.C4j += ptAGA10.argValue.adMixture[i] * adTableMri[i];
|
||||
}
|
||||
if (i >= 12 & i <= 18)
|
||||
{
|
||||
ptAGA10.argValue.C5j += ptAGA10.argValue.adMixture[i] * adTableMri[i];
|
||||
}
|
||||
if (i >= 14 & i <= 18)
|
||||
{
|
||||
ptAGA10.argValue.C6j += ptAGA10.argValue.adMixture[i] * adTableMri[i];
|
||||
}
|
||||
if (i == 3)
|
||||
{
|
||||
ptAGA10.argValue.C2 += ptAGA10.argValue.adMixture[i] * adTableMri[i];
|
||||
}
|
||||
|
||||
switch (ptAGA10.argValue.dCbtj)
|
||||
{
|
||||
case 2:
|
||||
ptAGA10.argValue.dZb11062 += adTableSqrtbj[0][i] * ptAGA10.argValue.adMixture[i];
|
||||
ptAGA10.argValue.dHhvMol += adTableHhvMol[0][i] * ptAGA10.argValue.adMixture[i];
|
||||
ptAGA10.argValue.dLhvMol += adTableLhvMol[0][i] * ptAGA10.argValue.adMixture[i];
|
||||
dZair = 0.99941;
|
||||
break;
|
||||
case 1:
|
||||
ptAGA10.argValue.dZb11062 += adTableSqrtbj[1][i] * ptAGA10.argValue.adMixture[i];
|
||||
ptAGA10.argValue.dHhvMol += adTableHhvMol[1][i] * ptAGA10.argValue.adMixture[i];
|
||||
ptAGA10.argValue.dLhvMol += adTableLhvMol[1][i] * ptAGA10.argValue.adMixture[i];
|
||||
dZair = 0.99958;
|
||||
break;
|
||||
case 0:
|
||||
ptAGA10.argValue.dZb11062 += adTableSqrtbj[2][i] * ptAGA10.argValue.adMixture[i];
|
||||
ptAGA10.argValue.dHhvMol += adTableHhvMol[2][i] * ptAGA10.argValue.adMixture[i];
|
||||
ptAGA10.argValue.dLhvMol += adTableLhvMol[2][i] * ptAGA10.argValue.adMixture[i];
|
||||
dZair = 0.99963;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ptAGA10.argValue.Bzsx = ptAGA10.argValue.Bzsx == 0?0: 1 / ptAGA10.argValue.Bzsx;
|
||||
ptAGA10.argValue.Bzxx = ptAGA10.argValue.Bzxx == 0?0: 1 / ptAGA10.argValue.Bzxx;
|
||||
|
||||
|
||||
ptAGA10.argValue.dZb11062 = 1 - ptAGA10.argValue.dZb11062 * ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.dHhvm = ptAGA10.argValue.dHhvMol / ptAGA10.argValue.dMrx;
|
||||
ptAGA10.argValue.dLhvm = ptAGA10.argValue.dLhvMol / ptAGA10.argValue.dMrx;
|
||||
ptAGA10.argValue.dHhvv = ptAGA10.argValue.dHhvMol * ptAGA10.argValue.dPb / ptAGA10.argValue.dTb / 8314.510 / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.dLhvv = ptAGA10.argValue.dLhvMol * ptAGA10.argValue.dPb / ptAGA10.argValue.dTb / 8314.510 / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.dRD_Ideal11062 = ptAGA10.argValue.dMrx / dMair;
|
||||
ptAGA10.argValue.dRD_Real11062 = ptAGA10.argValue.dRD_Ideal11062 * dZair / ptAGA10.argValue.dZb11062;
|
||||
|
||||
ptAGA10.argValue.dRhob11062 = ptAGA10.argValue.dMrx * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.dRhof11062 = ptAGA10.argValue.dMrx * ptAGA10.argValue.dPf / 8314.51 / ptAGA10.argValue.dTf / ptAGA10.argValue.dZf;
|
||||
ptAGA10.argValue.dWobbeIndex = ptAGA10.argValue.dHhvv / Math.sqrt(ptAGA10.argValue.dRD_Real11062);
|
||||
ptAGA10.argValue.C3j = ptAGA10.argValue.C4j + ptAGA10.argValue.adMixture[4] * adTableMri[4];
|
||||
ptAGA10.argValue.C2j = ptAGA10.argValue.C3j + ptAGA10.argValue.adMixture[3] * adTableMri[3];
|
||||
ptAGA10.argValue.C3C4 = ptAGA10.argValue.adMixture[4] * adTableMri[4] + ptAGA10.argValue.adMixture[10] * adTableMri[10] + ptAGA10.argValue.adMixture[11] * adTableMri[11];
|
||||
ptAGA10.argValue.TotalC = ptAGA10.argValue.C2j + ptAGA10.argValue.adMixture[0] * adTableMri[0];
|
||||
|
||||
ptAGA10.argValue.TotalC = ptAGA10.argValue.TotalC * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.C2 = ptAGA10.argValue.C2 * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.C3C4 = ptAGA10.argValue.C3C4 * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.C2j = ptAGA10.argValue.C2j * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.C3j = ptAGA10.argValue.C3j * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.C4j = ptAGA10.argValue.C4j * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.C5j = ptAGA10.argValue.C5j * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
ptAGA10.argValue.C6j = ptAGA10.argValue.C6j * ptAGA10.argValue.dPb / 8314.51 / ptAGA10.argValue.dTb / ptAGA10.argValue.dZb11062;
|
||||
|
||||
}
|
||||
}
|
741
src/main/java/com/ng/ngtools/modules/NG_Cal.java
Normal file
741
src/main/java/com/ng/ngtools/modules/NG_Cal.java
Normal file
@ -0,0 +1,741 @@
|
||||
package com.ng.ngtools.modules;
|
||||
|
||||
public class NG_Cal
|
||||
{
|
||||
public static final int NORMAL = 9000;
|
||||
public static final int NG_Cal_INITIALIZED = 9001;
|
||||
public static final int MEMORY_ALLOCATION_ERROR = 9002;
|
||||
public static final int GENERAL_CALCULATION_FAILURE = 9003;
|
||||
public static final int MAX_NUM_OF_ITERATIONS_EXCEEDED = 9004;
|
||||
public static final int NEGATIVE_DENSITY_DERIVATIVE = 9005;
|
||||
public static final int MAX_DENSITY_IN_BRAKET_EXCEEDED = 9006;
|
||||
/* number of components */
|
||||
public static final int NUMBEROFCOMPONENTS = 21;
|
||||
/* maximum number of tries within search routines */
|
||||
public static final int MAX_NUM_OF_ITERATIONS = 100;
|
||||
/* default tolerance limits */
|
||||
public static final double P_CHG_TOL = 0.001; // 0.001 Pa
|
||||
public static final double T_CHG_TOL = 0.001; // 0.001 of a Kelvin
|
||||
/* maximum allowable P & T */
|
||||
public static final double P_MAX = 1.379e8; // maximum pressure (Pa) ~= 20,000 psi
|
||||
public static final double P_MIN = 0.0; // maximum pressure = 0
|
||||
public static final double T_MAX = 473.15; // maximum temperature (K) ~= 392 F
|
||||
public static final double T_MIN = 143.0; // maximum temperature (K) ~= -200 F
|
||||
/* universal gas constant, in two configurations */
|
||||
public static final double RGASKJ = 8.314510e-3; // in kJ mol^-1 K^-1
|
||||
public static final double RGAS = 8.314510; // in J mol^-1 K^-1
|
||||
public Therm ptTherm;
|
||||
public Detail ptDetail;
|
||||
|
||||
//public struct SqgyParStruct //输气工艺相关参数
|
||||
//{
|
||||
// public int dCalName; //计算项目
|
||||
// public int dPipleD; //管道内径mm
|
||||
// public int dPipleDw; //管道内径外径mm
|
||||
// public int dPipleBh; //管道壁厚 mm
|
||||
// public double dPipleTotalLength; //管道总长度 km
|
||||
// public double dPiplePointLength; //管道任意点长度 km
|
||||
// public double dPstart; //起点压力终点压力MPa
|
||||
// public double dPend; //终点压力MPa
|
||||
// public double dFlow; //输气能力
|
||||
// public double dRd;//相对密度
|
||||
// public double dZf;//压缩因子
|
||||
// public double[] dNG_Compents;//天然气组分
|
||||
|
||||
// public double dPavg;//管道平均压力
|
||||
// public double dPavgPoint;//管道任意点的平均压力
|
||||
|
||||
|
||||
//}
|
||||
|
||||
public static void main(String[] args){
|
||||
System.out.println("ngtools");
|
||||
}
|
||||
|
||||
|
||||
/* FUNCTION PROTOTYPES */
|
||||
/* prototypes for initialization */
|
||||
// int NG_Cal_Init(void) ; /* initialize library */
|
||||
// int NG_Cal_UnInit(void) ; /* un-initialize library */
|
||||
//*** function prototype for basic VOS calculation */
|
||||
//*/
|
||||
// double SOS(ref AGA10.GasPropsSTRUCT ) ;
|
||||
//*** function prototype for a C* calculation */
|
||||
//*/
|
||||
// double Crit(ref AGA10.GasPropsSTRUCT , double) ;
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
* Function : NG_Cal_Init()
|
||||
* Arguments : void
|
||||
* Returns : int
|
||||
* Purpose : Initializes library; creates required objects
|
||||
* Revisions :
|
||||
**************************************************************************/
|
||||
|
||||
public final int NG_Cal_Init()
|
||||
{
|
||||
//create object for calculating density
|
||||
if (null == (ptDetail = new Detail()))
|
||||
{
|
||||
return MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
|
||||
//create object for calculating thermodynamic properties
|
||||
if (null == (ptTherm = new Therm()))
|
||||
{
|
||||
return MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
|
||||
return NG_Cal_INITIALIZED;
|
||||
|
||||
} // NG_Cal_Init
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
* Function : NG_Cal_UnInit()
|
||||
* Arguments : void
|
||||
* Returns : int
|
||||
* Purpose : Un-initializes library; deletes objects
|
||||
* Revisions :
|
||||
**************************************************************************/
|
||||
|
||||
public final int NG_Cal_UnInit()
|
||||
{
|
||||
// delete the objects (if they exist)
|
||||
ptDetail = null;
|
||||
ptTherm = null;
|
||||
return 0;
|
||||
|
||||
} // NG_Cal_UnInit
|
||||
|
||||
/**************************************************************************
|
||||
* Function : SOS()
|
||||
* Arguments : Pointers to external AGA10 data struct
|
||||
* Returns : double
|
||||
* Purpose : calculates speed of sound and other parameters
|
||||
* Revisions :
|
||||
**************************************************************************/
|
||||
|
||||
public final double SOS(com.ng.ngtools.tangible.RefObject<GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
// check if library is ready; initialize if necessary
|
||||
if (null == ptDetail || null == ptTherm)
|
||||
{
|
||||
NG_Cal_UnInit();
|
||||
NG_Cal_Init();
|
||||
|
||||
}
|
||||
|
||||
switch (ptAGA10.argValue.dCbtj)
|
||||
{
|
||||
case 2:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 273.15;
|
||||
break;
|
||||
case 1:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 288.15;
|
||||
break;
|
||||
case 0:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 293.15;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//Call function to calculate densities and thermodynamic properties
|
||||
com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail> tempRef_ptDetail = new com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail>(ptDetail);
|
||||
ptTherm.Run(ptAGA10, tempRef_ptDetail);
|
||||
ptDetail = tempRef_ptDetail.argValue;
|
||||
|
||||
//the basic sound speed calculation doesn't calculate C*; initialize to zero
|
||||
ptAGA10.argValue.dCstar = 0.0;
|
||||
|
||||
//return the speed of sound to caller
|
||||
|
||||
return ptAGA10.argValue.dSOS;
|
||||
|
||||
} // VOS()
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
* Function : Crit()
|
||||
* Arguments : Pointers to external AGA10 data struct, Detail and Therm
|
||||
* objects and a double precision float (gas velocity in plenum)
|
||||
* Returns : double
|
||||
* Purpose : calculates C*
|
||||
* Revisions :
|
||||
**************************************************************************/
|
||||
|
||||
public final double Crit(com.ng.ngtools.tangible.RefObject<GasPropsSTRUCT> ptAGA10, double dPlenumVelocity)
|
||||
{
|
||||
//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 == ptDetail || null == ptTherm)
|
||||
{
|
||||
NG_Cal_UnInit();
|
||||
|
||||
if (NG_Cal_INITIALIZED != NG_Cal_Init())
|
||||
{
|
||||
|
||||
ptAGA10.argValue.lStatus = MEMORY_ALLOCATION_ERROR;
|
||||
return 0.0;
|
||||
|
||||
}
|
||||
}
|
||||
switch (ptAGA10.argValue.dCbtj)
|
||||
{
|
||||
case 2:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 273.15;
|
||||
break;
|
||||
case 1:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 288.15;
|
||||
break;
|
||||
case 0:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 293.15;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
//begin by calculating densities and thermodynamic properties
|
||||
com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail> tempRef_ptDetail = new com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail>(ptDetail);
|
||||
ptTherm.Run(ptAGA10, tempRef_ptDetail);
|
||||
ptDetail = tempRef_ptDetail.argValue;
|
||||
|
||||
//DH is enthalpy change from plenum to throat; this is our initial guess
|
||||
|
||||
DH = (ptAGA10.argValue.dSOS * ptAGA10.argValue.dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0;
|
||||
|
||||
//trap plenum conditions before we alter the data stucture's contents
|
||||
S = ptAGA10.argValue.dS;
|
||||
H = ptAGA10.argValue.dH;
|
||||
R = ptAGA10.argValue.dRhof;
|
||||
P = ptAGA10.argValue.dPf;
|
||||
Z = ptAGA10.argValue.dZf;
|
||||
T = ptAGA10.argValue.dTf;
|
||||
|
||||
//initialize delta of DH to an arbitrary value outside of
|
||||
|
||||
//convergence tolerance
|
||||
DDH = 10.0;
|
||||
|
||||
//Via simple repetition, search for a pressure, temperature and sound speed
|
||||
|
||||
//at a nozzle throat which provide constant enthalpy, given the entropy known
|
||||
//at the plenum. Abort if loop executes more than 100 times without convergence.
|
||||
for (i = 1; i < MAX_NUM_OF_ITERATIONS; i++)
|
||||
{
|
||||
// calculate P and T to satisfy H and S
|
||||
com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail> tempRef_ptDetail2 = new com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail>(ptDetail);
|
||||
ptTherm.HS_Mode(ptAGA10, tempRef_ptDetail2, H - DH, S, true);
|
||||
ptDetail = tempRef_ptDetail2.argValue;
|
||||
|
||||
//calculate new thermo, including SOS
|
||||
com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail> tempRef_ptDetail3 = new com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail>(ptDetail);
|
||||
ptTherm.Run(ptAGA10, tempRef_ptDetail3);
|
||||
ptDetail = tempRef_ptDetail3.argValue;
|
||||
|
||||
//hold DH for tolerance check
|
||||
|
||||
DDH = DH;
|
||||
|
||||
// recalculate DH
|
||||
|
||||
DH = (ptAGA10.argValue.dSOS * ptAGA10.argValue.dSOS - dPlenumVelocity * dPlenumVelocity) / 2.0;
|
||||
|
||||
// end loop if tolerance reached
|
||||
|
||||
if (Math.abs(DDH - DH) < tolerance)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//C* is the real gas critical flow constant (not to be confused with Cperf or CRi)
|
||||
ptAGA10.argValue.dCstar = (ptAGA10.argValue.dRhof * ptAGA10.argValue.dSOS) / Math.sqrt(R * P * Z);
|
||||
|
||||
//put the original plenum pressure and temperature back
|
||||
|
||||
ptAGA10.argValue.dPf = P;
|
||||
ptAGA10.argValue.dTf = T;
|
||||
|
||||
//restore fluid props to plenum conditions
|
||||
com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail> tempRef_ptDetail4 = new com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail>(ptDetail);
|
||||
ptTherm.Run(ptAGA10, tempRef_ptDetail4);
|
||||
ptDetail = tempRef_ptDetail4.argValue;
|
||||
|
||||
GB11062 ptGB11062 = new GB11062();
|
||||
|
||||
ptGB11062.Run(ptAGA10);
|
||||
|
||||
//return the critical flow function to caller
|
||||
return ptAGA10.argValue.dCstar;
|
||||
|
||||
} // Crit()
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
* Function : Crit()
|
||||
* Arguments : Pointers to external AGA10 data struct, Detail and Therm
|
||||
* objects and a double precision float (gas velocity in plenum)
|
||||
* Returns : double
|
||||
* Purpose : calculates C*
|
||||
* Revisions :
|
||||
**************************************************************************/
|
||||
|
||||
public final double Zcal(com.ng.ngtools.tangible.RefObject<GasPropsSTRUCT> ptAGA10, double dPlenumVelocity)
|
||||
{
|
||||
//variables local to function
|
||||
|
||||
|
||||
|
||||
//check objects for readiness; try to initialize if not
|
||||
if (null == ptDetail || null == ptTherm)
|
||||
{
|
||||
NG_Cal_UnInit();
|
||||
|
||||
if (NG_Cal_INITIALIZED != NG_Cal_Init())
|
||||
{
|
||||
ptAGA10.argValue.lStatus = MEMORY_ALLOCATION_ERROR;
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
switch (ptAGA10.argValue.dCbtj)
|
||||
{
|
||||
case 0:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 293.15;
|
||||
break;
|
||||
case 1:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 288.15;
|
||||
break;
|
||||
case 2:
|
||||
ptAGA10.argValue.dPb = 101325;
|
||||
ptAGA10.argValue.dTb = 273.15;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//begin by calculating densities and thermodynamic properties
|
||||
com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail> tempRef_ptDetail = new com.ng.ngtools.tangible.RefObject<com.ng.ngtools.modules.Detail>(ptDetail);
|
||||
ptTherm.Run(ptAGA10, tempRef_ptDetail);
|
||||
ptDetail = tempRef_ptDetail.argValue;
|
||||
|
||||
|
||||
GB11062 ptGB11062 = new GB11062();
|
||||
|
||||
ptGB11062.Run(ptAGA10);
|
||||
|
||||
//return the critical flow function to caller
|
||||
return ptAGA10.argValue.dZf;
|
||||
|
||||
} // Z()
|
||||
|
||||
/**************************************************************************
|
||||
* Function : Cperf()
|
||||
* Arguments : pointer to external AGA10 data struct
|
||||
* Returns : double
|
||||
* Purpose : calculates isentropic perfect gas critical flow function
|
||||
* Revisions :
|
||||
**************************************************************************/
|
||||
|
||||
private double Cperf(com.ng.ngtools.tangible.RefObject<GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
|
||||
double k, root, exponent;
|
||||
|
||||
k = ptAGA10.argValue.dKappa;
|
||||
root = 2.0 / (k + 1.0);
|
||||
exponent = (k + 1.0) / (k - 1.0);
|
||||
|
||||
// isentropic perfect gas critical flow function C*i
|
||||
return (Math.sqrt(k * Math.pow(root, exponent)));
|
||||
|
||||
} // Cperf
|
||||
|
||||
/**************************************************************************
|
||||
* Function : CRi()
|
||||
* Arguments : pointer to external AGA10 data struct
|
||||
* Returns : double
|
||||
* Purpose : calculates isentropic real gas critical flow function CRi
|
||||
* Revisions :
|
||||
**************************************************************************/
|
||||
|
||||
private double CRi(com.ng.ngtools.tangible.RefObject<GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
return (Cperf(ptAGA10) / Math.sqrt(ptAGA10.argValue.dZf));
|
||||
} // CRi()
|
||||
|
||||
/* enumerations for tracking gas components */
|
||||
private enum gascomp
|
||||
{
|
||||
XiC1(0),
|
||||
XiN2(1),
|
||||
XiCO2(2),
|
||||
XiC2(3),
|
||||
XiC3(4),
|
||||
XiH2O(5),
|
||||
XiH2S(6),
|
||||
XiH2(7),
|
||||
XiCO(8),
|
||||
XiO2(9),
|
||||
XiIC4(10),
|
||||
XiNC4(11),
|
||||
XiIC5(12),
|
||||
XiNC5(13),
|
||||
XiNC6(14),
|
||||
XiNC7(15),
|
||||
XiNC8(16),
|
||||
XiNC9(17),
|
||||
XiNC10(18),
|
||||
XiHe(19),
|
||||
XiAr(20);
|
||||
|
||||
public static final int SIZE = Integer.SIZE;
|
||||
private static java.util.HashMap<Integer, gascomp> mappings;
|
||||
private final int intValue;
|
||||
gascomp(int value)
|
||||
{
|
||||
intValue = value;
|
||||
getMappings().put(value, this);
|
||||
}
|
||||
|
||||
private static java.util.HashMap<Integer, gascomp> getMappings()
|
||||
{
|
||||
if (mappings == null)
|
||||
{
|
||||
synchronized (gascomp.class)
|
||||
{
|
||||
if (mappings == null)
|
||||
{
|
||||
mappings = new java.util.HashMap<Integer, gascomp>();
|
||||
}
|
||||
}
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public static gascomp forValue(int value)
|
||||
{
|
||||
return getMappings().get(value);
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return intValue;
|
||||
}
|
||||
}
|
||||
|
||||
/* the main data structure used by this library */
|
||||
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class will differ from the original:
|
||||
//ORIGINAL LINE: public struct GasPropsSTRUCT
|
||||
public final static class GasPropsSTRUCT
|
||||
{ // corresponds to the control group in meter classes
|
||||
|
||||
public int lStatus; // calculation status 计算状态
|
||||
public boolean bForceUpdate; //执行全部计算的标志 signal to perform full calculation
|
||||
public double[] adMixture; //气体摩尔组成 Composition in mole fraction
|
||||
public double[] adMixtureV; //气体体积组成 Composition in mole fraction
|
||||
public double[] adMixtureD; //气体质量组成 Composition in mole fraction
|
||||
public int dCbtj; //参比条件 101325 0,15,20
|
||||
public double dPb; //参比压力 Contract base Pressure (Pa)
|
||||
public double dTb; // 参比温度Contract base temperature (K)
|
||||
public double dPf; //绝对压力 Absolute Pressure (Pa)
|
||||
public double dTf; //工况温度 Flowing temperature (K)
|
||||
// basic output from AGA 8 Detail method
|
||||
public double dMrx; //分子量 mixture molar mass
|
||||
public double dZb; // 标况压缩因子compressibility at contract base condition
|
||||
public double dZf; // 工况压缩因子compressibility at flowing condition
|
||||
public double dFpv; //超压缩系数 supercompressibility
|
||||
public double dDb; // 标况摩尔密度molar density at contract base conditions (moles/dm3)
|
||||
public double dDf; //工况摩尔密度 molar density at flowing conditions (moles/dm3)
|
||||
public double dRhob; // 标况质量密度mass density at contract base conditions (kg/m3)
|
||||
public double dRhof; //工况质量密度 mass density at flowing conditions (kg/m3)
|
||||
public double dRD_Ideal; // 理想气体的相对密度ideal gas relative density
|
||||
public double dRD_Real; // 真实气体的相对密度real gas relative density
|
||||
// additional output
|
||||
public double dHo; //理想气体的比焓 ideal gas specific enthalpy
|
||||
public double dH; //真实气体的焓 real gas specific enthalpy (J/kg)
|
||||
public double dS; // 真实气体的熵real gas specific entropy (J/kg-mol.K)
|
||||
public double dCpi; //理想气体定压热容 ideal gas constant pressure heat capacity (J/kg-mol.K)
|
||||
public double dCp; // 定压热容real gas constant pressure heat capacity (J/kg-mol.K)
|
||||
public double dCv; //定容积热容 real gas constant volume heat capacity (J/kg-mol.K)
|
||||
public double dk; // 比热比ratio of specific heats
|
||||
public double dKappa; //等熵指数 isentropic exponent, denoted with Greek letter kappa
|
||||
public double dSOS; // 声速speed of sound (m/s)
|
||||
public double dCstar; //临界流函数 critical flow factor C*
|
||||
|
||||
// 11062 输出
|
||||
|
||||
public double dHhvMol; //摩尔高位发热量
|
||||
public double dLhvMol; //摩尔低位发热量
|
||||
public double dHhvv; //体积高位发热量
|
||||
public double dLhvv; //体积低位发热量
|
||||
public double dHhvm; //质量高位发热量
|
||||
public double dLhvm; //质量地位发热量
|
||||
|
||||
public double dZb11062; //标况压缩因子
|
||||
public double dRhob11062; // 标况质量密度mass density at contract base conditions (kg/m3)
|
||||
public double dRhof11062; //工况质量密度 mass density at flowing conditions (kg/m3)
|
||||
public double dRD_Ideal11062; // 理想气体的相对密度ideal gas relative density
|
||||
public double dRD_Real11062; // 真实气体的相对密度real gas relative density
|
||||
public double dWobbeIndex; // 真实气体的沃泊指数
|
||||
|
||||
|
||||
public double Pc; // '临界压力
|
||||
public double TC; /// '临界温度
|
||||
public double Bzsx; // '爆炸上限
|
||||
public double Bzxx; // '爆炸下限
|
||||
public double TotalC; // '总炭含量 (kg/m3)
|
||||
public double C2; // 'C2组分含量 (kg/m3)
|
||||
public double C2j; // 'C2以上组分含量 (kg/m3)
|
||||
public double C3j; // 'C3以上组分含量 (kg/m3)
|
||||
public double C4j; // 'C4以上组分含量 (kg/m3)
|
||||
public double C5j; // 'C5以上组分含量 (kg/m3)
|
||||
public double C6j; // 'C6以上组分含量 (kg/m3)
|
||||
public double C3C4; // 'C3C4组分含量 (kg/m3)
|
||||
|
||||
|
||||
public GasPropsSTRUCT clone()
|
||||
{
|
||||
GasPropsSTRUCT varCopy = new GasPropsSTRUCT();
|
||||
|
||||
varCopy.lStatus = this.lStatus;
|
||||
varCopy.bForceUpdate = this.bForceUpdate;
|
||||
varCopy.adMixture = this.adMixture;
|
||||
varCopy.adMixtureV = this.adMixtureV;
|
||||
varCopy.adMixtureD = this.adMixtureD;
|
||||
varCopy.dCbtj = this.dCbtj;
|
||||
varCopy.dPb = this.dPb;
|
||||
varCopy.dTb = this.dTb;
|
||||
varCopy.dPf = this.dPf;
|
||||
varCopy.dTf = this.dTf;
|
||||
varCopy.dMrx = this.dMrx;
|
||||
varCopy.dZb = this.dZb;
|
||||
varCopy.dZf = this.dZf;
|
||||
varCopy.dFpv = this.dFpv;
|
||||
varCopy.dDb = this.dDb;
|
||||
varCopy.dDf = this.dDf;
|
||||
varCopy.dRhob = this.dRhob;
|
||||
varCopy.dRhof = this.dRhof;
|
||||
varCopy.dRD_Ideal = this.dRD_Ideal;
|
||||
varCopy.dRD_Real = this.dRD_Real;
|
||||
varCopy.dHo = this.dHo;
|
||||
varCopy.dH = this.dH;
|
||||
varCopy.dS = this.dS;
|
||||
varCopy.dCpi = this.dCpi;
|
||||
varCopy.dCp = this.dCp;
|
||||
varCopy.dCv = this.dCv;
|
||||
varCopy.dk = this.dk;
|
||||
varCopy.dKappa = this.dKappa;
|
||||
varCopy.dSOS = this.dSOS;
|
||||
varCopy.dCstar = this.dCstar;
|
||||
varCopy.dHhvMol = this.dHhvMol;
|
||||
varCopy.dLhvMol = this.dLhvMol;
|
||||
varCopy.dHhvv = this.dHhvv;
|
||||
varCopy.dLhvv = this.dLhvv;
|
||||
varCopy.dHhvm = this.dHhvm;
|
||||
varCopy.dLhvm = this.dLhvm;
|
||||
varCopy.dZb11062 = this.dZb11062;
|
||||
varCopy.dRhob11062 = this.dRhob11062;
|
||||
varCopy.dRhof11062 = this.dRhof11062;
|
||||
varCopy.dRD_Ideal11062 = this.dRD_Ideal11062;
|
||||
varCopy.dRD_Real11062 = this.dRD_Real11062;
|
||||
varCopy.dWobbeIndex = this.dWobbeIndex;
|
||||
varCopy.Pc = this.Pc;
|
||||
varCopy.TC = this.TC;
|
||||
varCopy.Bzsx = this.Bzsx;
|
||||
varCopy.Bzxx = this.Bzxx;
|
||||
varCopy.TotalC = this.TotalC;
|
||||
varCopy.C2 = this.C2;
|
||||
varCopy.C2j = this.C2j;
|
||||
varCopy.C3j = this.C3j;
|
||||
varCopy.C4j = this.C4j;
|
||||
varCopy.C5j = this.C5j;
|
||||
varCopy.C6j = this.C6j;
|
||||
varCopy.C3C4 = this.C3C4;
|
||||
|
||||
return varCopy;
|
||||
}
|
||||
}
|
||||
|
||||
//C# TO JAVA CONVERTER WARNING: Java does not allow user-defined value types. The behavior of this class will differ from the original:
|
||||
//ORIGINAL LINE: public struct FlowParStruct
|
||||
public final static class FlowParStruct //流量相关参数
|
||||
{
|
||||
//流量计算输入参数信息
|
||||
public int dFlowCalbz; //流量计算标准
|
||||
public int dZcalbz; //压缩因子计算标准
|
||||
public int dCbtj; //计量参比条件压力
|
||||
public double dPb_M; //计量参比条件压力
|
||||
public double dTb_M; //计量参比条件温度
|
||||
public double dPb_E; //燃烧参比条件压力
|
||||
public double dTb_E; //燃烧参比条件温度
|
||||
public double dPatm; //当地大气压
|
||||
public int dPatmUnit; //当地大气压单位
|
||||
public double[] dNG_Compents; //天然气组分
|
||||
|
||||
public int dMeterType; // 流量计类别
|
||||
public int dCoreType; //节流装置类型
|
||||
public int dPtmode; //取压方式
|
||||
public int dPipeType; // 管道类型
|
||||
public double dPipeD; //管道内径
|
||||
public int dLenUnit; //长度单位
|
||||
public double dPipeDtemp; //管道内径参考温度
|
||||
public int dPileDtempUint; //温度单位
|
||||
public double dPipeMaterial; //管道材料
|
||||
|
||||
public double dOrificeD; //孔板孔径
|
||||
public int dOrificeUnit; //长度单位
|
||||
public double dOrificeDtemp; //孔板内径参考温度
|
||||
public int dOrificeDtempUnit; //温度单位
|
||||
public double dOrificeMaterial; //孔板材料
|
||||
public int dOrificeSharpness; //锐利度系数计算方法
|
||||
public double dOrificeRk; //孔板入口圆弧半径
|
||||
public int dOrificeRkLenUint; //长度单位
|
||||
public double dPf; //输入压力
|
||||
public int dPfUnit; //压力单位
|
||||
public int dPfType; //压力类型
|
||||
public double dTf; //输入温度
|
||||
public int dTfUnit; //温度单位
|
||||
public double dDp; //输入差压
|
||||
public int dDpUnit; //压力单位
|
||||
public int dVFlowUnit; //体积流量单位
|
||||
public int dMFlowUnit; //'NG_Par(33) = ComboBox15.SelectedIndex '质量流量单位
|
||||
public int dEFlowUnit; //'NG_Par(34) = ComboBox16.SelectedIndex '能量流量单位
|
||||
public double dCd; //流出系数
|
||||
public double dCdCalMethod; //流出系数计算方法 0 检定证书 0回归公式
|
||||
public double dMeterFactor; //仪表系数
|
||||
public double dPulseNum; //脉冲数
|
||||
|
||||
public double dVFlowMax; //'NG_par(39)=’最大体积流量
|
||||
public double dVFlowMin; //'NG_par(40)=’最小体积流量
|
||||
public double dVFlowCon; //'NG_par(41)=’常用流量
|
||||
public double dPfRangeMin; //'NG_par(42)=’压力量程
|
||||
public double dPfRangeMax; //'NG_par(42)=’压力量程
|
||||
public double dDpRangeMin; //'NG_par(43)=’差压量程
|
||||
public double dDpRangeMax; //'NG_par(43)=’差压量程
|
||||
public double dTfRangeMin; //'NG_par(44)=’温度计量程
|
||||
public double dTfRangeMax; //'NG_par(44)=’温度计量程
|
||||
|
||||
public double dVGsc;// 管束车水容积
|
||||
|
||||
|
||||
//流量计算输出参数
|
||||
public double dE; //'求渐近速度系数 E
|
||||
public double dFG; //'求相对密度系数 FG
|
||||
public double dFT; //'求流动温度系数 'FT
|
||||
public double dDViscosity; //'求动力粘度 dlnd
|
||||
public double dDExpCoefficient; //'求可膨胀系数
|
||||
public double dRnPipe; //'管道雷诺数
|
||||
public double dBk; //'孔板锐利度系数Bk
|
||||
public double dRoughNessPipe; //'管道粗糙度系数 Gme
|
||||
public double dCdCorrect; //'修正后的流出系数
|
||||
public double dCdNozell; //'喷嘴的流出系数
|
||||
public double dVFlowb; //'标况体积流量 m³、s
|
||||
public double dVFlowf; //'工况体积流量
|
||||
public double dMFlowb; //'标况质量流量
|
||||
public double dEFlowb; //'标况能量流量
|
||||
public double dVelocityFlow; //'管道内天然气流速
|
||||
public double dPressLost; //'压力损失
|
||||
public double dBeta; //'直径比
|
||||
public double dKappa; //'等熵指数
|
||||
|
||||
public double dVCNG; //'CNG体积
|
||||
|
||||
|
||||
|
||||
public FlowParStruct clone()
|
||||
{
|
||||
FlowParStruct varCopy = new FlowParStruct();
|
||||
|
||||
varCopy.dFlowCalbz = this.dFlowCalbz;
|
||||
varCopy.dZcalbz = this.dZcalbz;
|
||||
varCopy.dCbtj = this.dCbtj;
|
||||
varCopy.dPb_M = this.dPb_M;
|
||||
varCopy.dTb_M = this.dTb_M;
|
||||
varCopy.dPb_E = this.dPb_E;
|
||||
varCopy.dTb_E = this.dTb_E;
|
||||
varCopy.dPatm = this.dPatm;
|
||||
varCopy.dPatmUnit = this.dPatmUnit;
|
||||
varCopy.dNG_Compents = this.dNG_Compents;
|
||||
varCopy.dMeterType = this.dMeterType;
|
||||
varCopy.dCoreType = this.dCoreType;
|
||||
varCopy.dPtmode = this.dPtmode;
|
||||
varCopy.dPipeType = this.dPipeType;
|
||||
varCopy.dPipeD = this.dPipeD;
|
||||
varCopy.dLenUnit = this.dLenUnit;
|
||||
varCopy.dPipeDtemp = this.dPipeDtemp;
|
||||
varCopy.dPileDtempUint = this.dPileDtempUint;
|
||||
varCopy.dPipeMaterial = this.dPipeMaterial;
|
||||
varCopy.dOrificeD = this.dOrificeD;
|
||||
varCopy.dOrificeUnit = this.dOrificeUnit;
|
||||
varCopy.dOrificeDtemp = this.dOrificeDtemp;
|
||||
varCopy.dOrificeDtempUnit = this.dOrificeDtempUnit;
|
||||
varCopy.dOrificeMaterial = this.dOrificeMaterial;
|
||||
varCopy.dOrificeSharpness = this.dOrificeSharpness;
|
||||
varCopy.dOrificeRk = this.dOrificeRk;
|
||||
varCopy.dOrificeRkLenUint = this.dOrificeRkLenUint;
|
||||
varCopy.dPf = this.dPf;
|
||||
varCopy.dPfUnit = this.dPfUnit;
|
||||
varCopy.dPfType = this.dPfType;
|
||||
varCopy.dTf = this.dTf;
|
||||
varCopy.dTfUnit = this.dTfUnit;
|
||||
varCopy.dDp = this.dDp;
|
||||
varCopy.dDpUnit = this.dDpUnit;
|
||||
varCopy.dVFlowUnit = this.dVFlowUnit;
|
||||
varCopy.dMFlowUnit = this.dMFlowUnit;
|
||||
varCopy.dEFlowUnit = this.dEFlowUnit;
|
||||
varCopy.dCd = this.dCd;
|
||||
varCopy.dCdCalMethod = this.dCdCalMethod;
|
||||
varCopy.dMeterFactor = this.dMeterFactor;
|
||||
varCopy.dPulseNum = this.dPulseNum;
|
||||
varCopy.dVFlowMax = this.dVFlowMax;
|
||||
varCopy.dVFlowMin = this.dVFlowMin;
|
||||
varCopy.dVFlowCon = this.dVFlowCon;
|
||||
varCopy.dPfRangeMin = this.dPfRangeMin;
|
||||
varCopy.dPfRangeMax = this.dPfRangeMax;
|
||||
varCopy.dDpRangeMin = this.dDpRangeMin;
|
||||
varCopy.dDpRangeMax = this.dDpRangeMax;
|
||||
varCopy.dTfRangeMin = this.dTfRangeMin;
|
||||
varCopy.dTfRangeMax = this.dTfRangeMax;
|
||||
varCopy.dVGsc = this.dVGsc;
|
||||
|
||||
varCopy.dE = this.dE;
|
||||
varCopy.dFG = this.dFG;
|
||||
varCopy.dFT = this.dFT;
|
||||
varCopy.dDViscosity = this.dDViscosity;
|
||||
varCopy.dDExpCoefficient = this.dDExpCoefficient;
|
||||
varCopy.dRnPipe = this.dRnPipe;
|
||||
varCopy.dBk = this.dBk;
|
||||
varCopy.dRoughNessPipe = this.dRoughNessPipe;
|
||||
varCopy.dCdCorrect = this.dCdCorrect;
|
||||
varCopy.dCdNozell = this.dCdNozell;
|
||||
varCopy.dVFlowb = this.dVFlowb;
|
||||
varCopy.dVFlowf = this.dVFlowf;
|
||||
varCopy.dMFlowb = this.dMFlowb;
|
||||
varCopy.dEFlowb = this.dEFlowb;
|
||||
varCopy.dVelocityFlow = this.dVelocityFlow;
|
||||
varCopy.dPressLost = this.dPressLost;
|
||||
varCopy.dBeta = this.dBeta;
|
||||
varCopy.dKappa = this.dKappa;
|
||||
varCopy.dVCNG = this.dVCNG;
|
||||
|
||||
|
||||
return varCopy;
|
||||
}
|
||||
}
|
||||
}
|
607
src/main/java/com/ng/ngtools/modules/Therm.java
Normal file
607
src/main/java/com/ng/ngtools/modules/Therm.java
Normal file
@ -0,0 +1,607 @@
|
||||
package com.ng.ngtools.modules;
|
||||
|
||||
public class Therm
|
||||
{
|
||||
// member data
|
||||
//double dT;// current temperature, in Kelvins
|
||||
//double dP;// current pressure, in Pascals
|
||||
//double dD;// molar density, in moles/dm3
|
||||
//double dRho;// mass density, in kg/m3
|
||||
private double dPdD; // partial deriv of P wrt D
|
||||
private double dPdT; // partial deriv of P wrt T
|
||||
private double dSi; // ideal gas specific entropy, kJ/kg.K
|
||||
private double dTold; // temperature previously used
|
||||
private double dMrxold; // mixture molar mass previously used
|
||||
private final double[] GK_root = new double[] {0.14887433898163121088, 0.43339539412924719080, 0.67940956829902440263, 0.86506336668898451073, 0.97390652851717172008};
|
||||
private final double[] GK_weight = new double[] {0.29552422471475286217, 0.26926671930999634918, 0.21908636251598204295, 0.14945134915058059038, 0.066671344308688137179};
|
||||
//set the number of points for quadrature
|
||||
private final int GK_points = 5;
|
||||
//equation constants for ideal gas heat capacity, enthalpy and entropy
|
||||
private final double[][] ThermConstants = new double[][]
|
||||
{
|
||||
{-29776.4, 7.95454, 43.9417, 1037.09, 1.56373, 813.205, -24.9027, 1019.98, -10.1601, 1070.14, -20.0615},
|
||||
{-3495.34, 6.95587, 0.272892, 662.738, -0.291318, -680.562, 1.78980, 1740.06, 0.0, 100.0, 4.49823},
|
||||
{20.7307, 6.96237, 2.68645, 500.371, -2.56429, -530.443, 3.91921, 500.198, 2.13290, 2197.22, 5.81381},
|
||||
{-37524.4, 7.98139, 24.3668, 752.320, 3.53990, 272.846, 8.44724, 1020.13, -13.2732, 869.510, -22.4010},
|
||||
{-56072.1, 8.14319, 37.0629, 735.402, 9.38159, 247.190, 13.4556, 1454.78, -11.7342, 984.518, -24.0426},
|
||||
{-13773.1, 7.97183, 6.27078, 2572.63, 2.05010, 1156.72, 0.0, 100.0, 0.0, 100.0, -3.24989},
|
||||
{-10085.4, 7.94680, -0.08380, 433.801, 2.85539, 843.792, 6.31595, 1481.43, -2.88457, 1102.23, -0.51551},
|
||||
{-5565.60, 6.66789, 2.33458, 2584.98, .749019, 559.656, 0.0, 100.0, 0.0, 100.0, -7.94821},
|
||||
{-2753.49, 6.95854, 2.02441, 1541.22, .096774, 3674.81, 0.0, 100.0, 0.0, 100.0, 6.23387},
|
||||
{-3497.45, 6.96302, 2.40013, 2522.05, 2.21752, 1154.15, 0.0, 100.0, 0.0, 100.0, 9.19749},
|
||||
{-72387.0, 17.8143, 58.2062, 1787.39, 40.7621, 808.645, 0.0, 100.0, 0.0, 100.0, -44.1341},
|
||||
{-72674.8, 18.6383, 57.4178, 1792.73, 38.6599, 814.151, 0.0, 100.0, 0.0, 100.0, -46.1938},
|
||||
{-91505.5, 21.3861, 74.3410, 1701.58, 47.0587, 775.899, 0.0, 100.0, 0.0, 100.0, -60.2474},
|
||||
{-83845.2, 22.5012, 69.5789, 1719.58, 46.2164, 802.174, 0.0, 100.0, 0.0, 100.0, -62.2197},
|
||||
{-94982.5, 26.6225, 80.3819, 1718.49, 55.6598, 802.069, 0.0, 100.0, 0.0, 100.0, -77.5366},
|
||||
{-103353.0, 30.4029, 90.6941, 1669.32, 63.2028, 786.001, 0.0, 100.0, 0.0, 100.0, -92.0164},
|
||||
{-109674.0, 34.0847, 100.253, 1611.55, 69.7675, 768.847, 0.0, 100.0, 0.0, 100.0, -106.149},
|
||||
{-122599.0, 38.5014, 111.446, 1646.48, 80.5015, 781.588, 0.0, 100.0, 0.0, 100.0, -122.444},
|
||||
{-133564.0, 42.7143, 122.173, 1654.85, 90.2255, 785.564, 0.0, 100.0, 0.0, 100.0, -138.006},
|
||||
{0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0},
|
||||
{0.0, 4.9680, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0}
|
||||
};
|
||||
// enumerations for indexing of coefficients
|
||||
//public enum CoefficientList { coefA = 0, coefB, coefC, coefD, coefE, coefF, coefG, coefH, coefI, coefJ, coefK } ;
|
||||
public int coefA = 0;
|
||||
public int coefB = 1;
|
||||
public int coefC = 2;
|
||||
public int coefD = 3;
|
||||
public int coefE = 4;
|
||||
public int coefF = 5;
|
||||
public int coefG = 6;
|
||||
public int coefH = 7;
|
||||
public int coefI = 8;
|
||||
public int coefJ = 9;
|
||||
public int coefK = 10;
|
||||
// conversion constant for thermochemical calories to Joules: 1 cal(IT) = 4.1840 J
|
||||
private static final double CalTH = 4.1840;
|
||||
public Therm()
|
||||
{
|
||||
// initialize 3 history-sensitive variables
|
||||
dSi = 0.0;
|
||||
dTold = 0.0;
|
||||
dMrxold = 0.0;
|
||||
} //Therm()
|
||||
/**************************************************************************
|
||||
*Function:Math.Coth()
|
||||
*Arguments:double
|
||||
*Returns:double
|
||||
*Purpose:calculate hyperbolic cotangent; used in Ho calculations
|
||||
*Revisions:
|
||||
*Notes:Not a Therm object class member, just a utility for this
|
||||
*file. The C++ language has no intrinsic support for
|
||||
*hyperbolic cotangent
|
||||
**************************************************************************/
|
||||
private double coth(double x)
|
||||
{
|
||||
return Math.cosh(x) / Math.sinh(x);
|
||||
} // Math.Coth()
|
||||
/**************************************************************************
|
||||
*Function:Run()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT , Detail *
|
||||
*Returns:void
|
||||
*Purpose:overall execution control; top level math for SOS and k
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
public final void Run(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10, com.ng.ngtools.tangible.RefObject<Detail> ptD)
|
||||
{
|
||||
//local variables
|
||||
double c, x, y, z;
|
||||
//first run basic set of functions within AGA 8 (1994) Detail Method
|
||||
ptD.argValue.Run(ptAGA10);
|
||||
//find first partial derivative of Z wrt D
|
||||
ptD.argValue.dZdD(ptAGA10.argValue.dDf);
|
||||
//find real gas cv, cp, specific enthalpy and entropy
|
||||
CprCvrHS(ptAGA10, ptD);
|
||||
//ratio of real gas specific heats
|
||||
ptAGA10.argValue.dk = ptAGA10.argValue.dCp / ptAGA10.argValue.dCv;
|
||||
//solve c in three steps, for clarity and ease of debugging
|
||||
x = ptAGA10.argValue.dk * NG_Cal.RGAS * 1000.0 * ptAGA10.argValue.dTf;
|
||||
y = ptAGA10.argValue.dMrx;
|
||||
z = ptAGA10.argValue.dZf + ptAGA10.argValue.dDf * ptD.argValue.ddZdD;
|
||||
//calculate c, which is SOS^2
|
||||
c = (x / y) * z;
|
||||
//speed of sound
|
||||
ptAGA10.argValue.dSOS = Math.sqrt(c);
|
||||
//calculate the real gas isentropic exponent
|
||||
//using expression functionally equivalent to Equation 3.2
|
||||
ptAGA10.argValue.dKappa = (c * ptAGA10.argValue.dRhof) / ptAGA10.argValue.dPf;
|
||||
} //Run()
|
||||
/**************************************************************************
|
||||
*Function:CpiMolar()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT
|
||||
*Returns:double
|
||||
*Purpose:Calculate constant pressure ideal gas molar heat capacity
|
||||
*in (J/mol-K), applying eqns from Aly, Lee, McFall
|
||||
*Notes:For continuity, the original constants and eqn's have been
|
||||
*retained. Conversion from thermochemical calories(th) to
|
||||
*Joules is applied after the primary calculations are complete.
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
private double CpiMolar(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
double Cp = 0.0;
|
||||
double Cpx;
|
||||
double DT, FT, HT, JT;
|
||||
double Dx, Fx, Hx, Jx;
|
||||
double T;
|
||||
int i;
|
||||
//to maximize readability of this section, use intermediate variable T
|
||||
T = ptAGA10.argValue.dTf;
|
||||
//calculate heat capacity for each component
|
||||
for (i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
//skip species whose concentration is zero
|
||||
if (ptAGA10.argValue.adMixture[i] <= 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//initialize Cp of species to zero
|
||||
Cpx = 0.0;
|
||||
// calculate species intermediate terms
|
||||
DT = ThermConstants[i][coefD] / T;
|
||||
FT = ThermConstants[i][coefF] / T;
|
||||
HT = ThermConstants[i][coefH] / T;
|
||||
JT = ThermConstants[i][coefJ] / T;
|
||||
// use intermediate terms to avoid redundant calcs
|
||||
Dx = DT / Math.sinh(DT);
|
||||
Fx = FT / Math.cosh(FT);
|
||||
Hx = HT / Math.sinh(HT);
|
||||
Jx = JT / Math.cosh(JT);
|
||||
Cpx += ThermConstants[i][coefB];
|
||||
Cpx += ThermConstants[i][coefC] * Dx * Dx;
|
||||
Cpx += ThermConstants[i][coefE] * Fx * Fx;
|
||||
Cpx += ThermConstants[i][coefG] * Hx * Hx;
|
||||
Cpx += ThermConstants[i][coefI] * Jx * Jx;
|
||||
//use current mole fraction to weight the contribution
|
||||
Cpx *= ptAGA10.argValue.adMixture[i];
|
||||
//add this contribution to the sum
|
||||
Cp += Cpx;
|
||||
}
|
||||
// convert from cal(th)/mol-K to J/mol-K
|
||||
Cp *= CalTH;
|
||||
return Cp;
|
||||
} //CpiMolar()
|
||||
/**************************************************************************
|
||||
*Function:Ho()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT
|
||||
*Returns:double
|
||||
*Purpose:Calculate ideal gas specific enthalpy (J/kg)
|
||||
*Notes:For continuity, the original constants and eqn's have been
|
||||
*retained. Conversion from thermochemical calories(th) to
|
||||
*Joules is applied after the primary calculations are complete.
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
private double Ho(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
double H = 0.0;
|
||||
double Hx;
|
||||
double DT, FT, HT, JT;
|
||||
double cothDT, tanhFT, cothHT, tanhJT;
|
||||
double T;
|
||||
int i;
|
||||
// to maximize readability of this section, use intermediate variable T
|
||||
T = ptAGA10.argValue.dTf;
|
||||
for (i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
// skip species whose concentration is zero
|
||||
if (ptAGA10.argValue.adMixture[i] <= 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Hx = 0.0;
|
||||
// calculate species intermediate terms
|
||||
DT = ThermConstants[i][coefD] / T;
|
||||
FT = ThermConstants[i][coefF] / T;
|
||||
HT = ThermConstants[i][coefH] / T;
|
||||
JT = ThermConstants[i][coefJ] / T;
|
||||
cothDT = coth(DT);
|
||||
tanhFT = Math.tanh(FT);
|
||||
cothHT = coth(HT);
|
||||
tanhJT = Math.tanh(JT);
|
||||
Hx += ThermConstants[i][coefA];
|
||||
Hx += ThermConstants[i][coefB] * T;
|
||||
Hx += ThermConstants[i][coefC] * ThermConstants[i][coefD] * cothDT;
|
||||
Hx -= ThermConstants[i][coefE] * ThermConstants[i][coefF] * tanhFT;
|
||||
Hx += ThermConstants[i][coefG] * ThermConstants[i][coefH] * cothHT;
|
||||
Hx -= ThermConstants[i][coefI] * ThermConstants[i][coefJ] * tanhJT;
|
||||
//use current mole fraction to weight the contribution
|
||||
Hx *= ptAGA10.argValue.adMixture[i];
|
||||
//add this contribution to the sum
|
||||
H += Hx;
|
||||
}
|
||||
//convert from cal(th)/g-mol to kJ/kg-mol
|
||||
H *= CalTH;
|
||||
//convert from kJ/kg-mol to J/kg
|
||||
H /= ptAGA10.argValue.dMrx;
|
||||
// return in J/kg
|
||||
return H * 1.0e3;
|
||||
}
|
||||
// Ho()
|
||||
/**************************************************************************
|
||||
*Function:So()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT
|
||||
*Returns:double
|
||||
*Purpose:ideal gas specific entropy (J/kg-K)
|
||||
*Notes:For continuity, the original constants and eqn's have been
|
||||
*retained. Conversion from thermochemical calories(th) to
|
||||
*Joules is applied after the primary calculations are complete.
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
private double So(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10)
|
||||
{
|
||||
double S = 0.0;
|
||||
double Sx;
|
||||
double DT, FT, HT, JT;
|
||||
double cothDT, tanhFT, cothHT, tanhJT;
|
||||
double sinhDT, coshFT, sinhHT, coshJT;
|
||||
double T;
|
||||
int i;
|
||||
// to improve readability of this section, use intermediate variable T
|
||||
T = ptAGA10.argValue.dTf;
|
||||
for (i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
// skip species whose concentration is zero
|
||||
if (ptAGA10.argValue.adMixture[i] <= 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Sx = 0.0;
|
||||
// calculate species intermediate terms
|
||||
DT = ThermConstants[i][coefD] / T;
|
||||
FT = ThermConstants[i][coefF] / T;
|
||||
HT = ThermConstants[i][coefH] / T;
|
||||
JT = ThermConstants[i][coefJ] / T;
|
||||
cothDT = coth(DT);
|
||||
tanhFT = Math.tanh(FT);
|
||||
cothHT = coth(HT);
|
||||
tanhJT = Math.tanh(JT);
|
||||
sinhDT = Math.sinh(DT);
|
||||
coshFT = Math.cosh(FT);
|
||||
sinhHT = Math.sinh(HT);
|
||||
coshJT = Math.cosh(JT);
|
||||
Sx += ThermConstants[i][coefK];
|
||||
Sx += ThermConstants[i][coefB] * Math.log(T);
|
||||
Sx += ThermConstants[i][coefC] * (DT * cothDT - Math.log(sinhDT));
|
||||
Sx -= ThermConstants[i][coefE] * (FT * tanhFT - Math.log(coshFT));
|
||||
Sx += ThermConstants[i][coefG] * (HT * cothHT - Math.log(sinhHT));
|
||||
Sx -= ThermConstants[i][coefI] * (JT * tanhJT - Math.log(coshJT));
|
||||
//use current mole fraction to weight the contribution
|
||||
Sx *= ptAGA10.argValue.adMixture[i];
|
||||
//add this contribution to the sum
|
||||
S += Sx;
|
||||
}
|
||||
//convert cal(th)/mol-K basis to to kJ/kg mol-K
|
||||
S *= CalTH;
|
||||
//convert from kJ/kg mol-K to kJ/kg-K
|
||||
S /= ptAGA10.argValue.dMrx;
|
||||
// return in J/kg-K
|
||||
return S * 1.0e3;
|
||||
} //So()
|
||||
/**************************************************************************
|
||||
*Function:CprCvrHS()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT , Detail *
|
||||
*Returns:void
|
||||
*Purpose:reasonably efficient group calculation of Cp, Cv, H and S
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
private void CprCvrHS(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10, com.ng.ngtools.tangible.RefObject<Detail> ptD)
|
||||
{
|
||||
double Cvinc, Cvr, Cpr;
|
||||
double Hinc;
|
||||
double Sinc;
|
||||
double Smixing;
|
||||
double Cp, Si;
|
||||
double a, b, x;
|
||||
int i;
|
||||
//initialize integrals to zero
|
||||
Cvinc = 0.0;
|
||||
Hinc = 0.0;
|
||||
Sinc = 0.0;
|
||||
//initialize entropy of mixing
|
||||
Smixing = 0.0;
|
||||
//find ideal gas Cp
|
||||
Cp = CpiMolar(ptAGA10);
|
||||
//find ideal gas enthalpy
|
||||
ptAGA10.argValue.dHo = Ho(ptAGA10);
|
||||
//find ideal gas entropy
|
||||
Si = So(ptAGA10);
|
||||
//calculate ideal gas specific heat capacity at constant pressure in J/kgK
|
||||
ptAGA10.argValue.dCpi = (Cp * 1000.0) / ptAGA10.argValue.dMrx;
|
||||
//integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature
|
||||
for (i = 0; i < GK_points; i++)
|
||||
{
|
||||
// set calculation point at + abscissa
|
||||
x = ptAGA10.argValue.dDf * (1.0 + GK_root[i]) / 2.0;
|
||||
//get Z at D
|
||||
ptD.argValue.zdetail(x);
|
||||
ptD.argValue.dZdT(x);
|
||||
ptD.argValue.d2ZdT2(x);
|
||||
//gather contributions at + abscissa; applying weighting factor
|
||||
Hinc += GK_weight[i] * ptD.argValue.ddZdT / x;
|
||||
Cvinc += GK_weight[i] * (2.0 * ptD.argValue.ddZdT + ptAGA10.argValue.dTf * ptD.argValue.dd2ZdT2) / x;
|
||||
Sinc += GK_weight[i] * (ptD.argValue.dZ + ptAGA10.argValue.dTf * ptD.argValue.ddZdT - 1.0) / x;
|
||||
//set calculation point at - abscissa
|
||||
x = ptAGA10.argValue.dDf * (1.0 - GK_root[i]) / 2.0;
|
||||
//get Z at D
|
||||
ptD.argValue.zdetail(x);
|
||||
//calculate 1st and 2nd partial derivatives of Z wrt T
|
||||
ptD.argValue.dZdT(x);
|
||||
ptD.argValue.d2ZdT2(x);
|
||||
//gather contributions at - abscissa; applying weighting factor
|
||||
Hinc += GK_weight[i] * ptD.argValue.ddZdT / x;
|
||||
Cvinc += GK_weight[i] * (2.0 * ptD.argValue.ddZdT + ptAGA10.argValue.dTf * ptD.argValue.dd2ZdT2) / x;
|
||||
Sinc += GK_weight[i] * (ptD.argValue.dZ + ptAGA10.argValue.dTf * ptD.argValue.ddZdT - 1.0) / x;
|
||||
}
|
||||
//return Z and partial derivatives to full molar density
|
||||
ptD.argValue.zdetail(ptAGA10.argValue.dDf);
|
||||
ptD.argValue.dZdT(ptAGA10.argValue.dDf);
|
||||
ptD.argValue.d2ZdT2(ptAGA10.argValue.dDf);
|
||||
//complete Cv molar
|
||||
Cvr = Cp - NG_Cal.RGAS * (1.0 + ptAGA10.argValue.dTf * Cvinc * 0.5 * ptAGA10.argValue.dDf);
|
||||
//intermediate values for Cp, containing 2 partial derivatives
|
||||
a = (ptAGA10.argValue.dZf + ptAGA10.argValue.dTf * ptD.argValue.ddZdT);
|
||||
b = (ptAGA10.argValue.dZf + ptAGA10.argValue.dDf * ptD.argValue.ddZdD);
|
||||
//calculate dPdT, the partial derivative of P wrt T, at D
|
||||
dPdT = NG_Cal.RGAS * ptAGA10.argValue.dDf * a;
|
||||
//calculate dPdD, the partial derivative of P wrt D, at T
|
||||
dPdD = NG_Cal.RGAS * ptAGA10.argValue.dTf * b;
|
||||
//equation completing molar Cp, cancelling appropriate terms
|
||||
Cpr = Cvr + NG_Cal.RGAS * ((a * a) / b);
|
||||
//change from molar to mass basis
|
||||
Cpr /= ptAGA10.argValue.dMrx;
|
||||
Cvr /= ptAGA10.argValue.dMrx;
|
||||
// write to the data stucture
|
||||
ptAGA10.argValue.dCv = Cvr * 1000.0; // convert from joules/kgK to kilojoules/kgK
|
||||
ptAGA10.argValue.dCp = Cpr * 1000.0;
|
||||
// calculate specific enthalpy
|
||||
ptAGA10.argValue.dH = ptAGA10.argValue.dHo + 1000.0 * NG_Cal.RGAS * ptAGA10.argValue.dTf * (ptAGA10.argValue.dZf - 1.0 - ptAGA10.argValue.dTf * Hinc * 0.5 * ptAGA10.argValue.dDf) / ptAGA10.argValue.dMrx;
|
||||
// calculate entropy of mixing
|
||||
for (i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
if (ptAGA10.argValue.adMixture[i] != 0)
|
||||
{
|
||||
Smixing += ptAGA10.argValue.adMixture[i] * Math.log(ptAGA10.argValue.adMixture[i]);
|
||||
}
|
||||
}
|
||||
Smixing *= NG_Cal.RGAS;
|
||||
// calculate specific entropy
|
||||
ptAGA10.argValue.dS = Si - Smixing - 1000.0 * NG_Cal.RGAS * (Math.log(ptAGA10.argValue.dPf / 101325.0) - Math.log(ptAGA10.argValue.dZf) + Sinc * 0.5 * ptAGA10.argValue.dDf) / ptAGA10.argValue.dMrx;
|
||||
} //CprCvrHS()
|
||||
/**************************************************************************
|
||||
*Function:HS_Mode()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT , Detail *, double, double, bool
|
||||
*Returns:void
|
||||
*Purpose:Calculates a pressure & temperature from known enthalpy & entropy,
|
||||
*with or without prior estimates.This function has a role in the
|
||||
*calculation of C*.
|
||||
*Solution based on a doubly-nested trial & error algorithm and Newton's
|
||||
*method.
|
||||
*
|
||||
*For illustrative purpose, two approaches are supported by this example.
|
||||
*If you are starting without advance knowledge of P & T, set the input parm
|
||||
*bGuess to false, thus specifying a conservative search approach.
|
||||
*If, however, you have a basis for guessing P & T (plenum conditions of a
|
||||
*critical flow nozzle, for example) set P & T via GasPropsSTRUCT and set
|
||||
*bGuess = true. The initial guess allows the search function to be more
|
||||
*aggressive and, typically, faster.
|
||||
*
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
public final void HS_Mode(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10, com.ng.ngtools.tangible.RefObject<Detail> ptD, double H, double S, boolean bGuess)
|
||||
{
|
||||
double s0, s1, s2, t0, t1, t2, tmin, tmax;
|
||||
double h0, h1, h2, p0, p1, p2, px, pmin, pmax;
|
||||
double delta1, delta2;
|
||||
double tolerance = 0.001; // convergence tolerance (used for both H and S searches)
|
||||
int i, j;
|
||||
//s0and h0 are our real gas reference points
|
||||
s0 = S;
|
||||
h0 = H;
|
||||
//calling function specifies whether search parameters are supplied thru ptAGA10 or unknown
|
||||
if (bGuess)
|
||||
{
|
||||
t1 = ptAGA10.argValue.dTf;
|
||||
px = ptAGA10.argValue.dPf;
|
||||
pmax = px * 2.0;
|
||||
pmin = px * 0.1;
|
||||
tmax = t1 * 1.5;
|
||||
tmin = t1 * 0.67;
|
||||
}
|
||||
else // use arbitrary, generic limits
|
||||
{
|
||||
t1 = 273.15;
|
||||
px = 1013250.0; // 10 atmospheres
|
||||
pmax = NG_Cal.P_MAX;
|
||||
pmin = 10000.0; // 10 kPa
|
||||
tmax = NG_Cal.T_MAX;
|
||||
tmin = NG_Cal.T_MIN;
|
||||
}
|
||||
// set the temperature differential
|
||||
t2 = t1 + 10.0;
|
||||
///////////////////////////////////////////
|
||||
//begin double trial-and-error, searching for T & P
|
||||
//run the calculation with initial guesses
|
||||
ptD.argValue.Run(ptAGA10);
|
||||
//h1 is difference between h given and h@Tf, Pf
|
||||
h1 = this.H(ptAGA10, ptD) - h0;
|
||||
//outer loop: search for a t2 which will satisfy constant enthalpy
|
||||
for (i = 0; i < NG_Cal.MAX_NUM_OF_ITERATIONS; i++)
|
||||
{
|
||||
ptAGA10.argValue.dTf = t2;
|
||||
p1 = px; // reset one bracket
|
||||
p2 = px * 0.1; // set other bracket to 0.1x the upper bracket
|
||||
ptAGA10.argValue.dPf = p1;
|
||||
ptD.argValue.Run(ptAGA10);
|
||||
s1 = this.S(ptAGA10, ptD) - s0;
|
||||
//inside loop: search for a p2 which will satisfy constant entropy
|
||||
for (j = 0; j < NG_Cal.MAX_NUM_OF_ITERATIONS; j++)
|
||||
{
|
||||
ptAGA10.argValue.dPf = p2;
|
||||
ptD.argValue.Run(ptAGA10);
|
||||
s2 = this.S(ptAGA10, ptD) - s0;
|
||||
//calculate our proportional change
|
||||
delta2 = Math.abs(s1 - s2) / s0; // close enough?
|
||||
if (delta2 < tolerance)
|
||||
{
|
||||
break;
|
||||
}
|
||||
//revise our estimate to p2
|
||||
p0 = p2;
|
||||
p2 = (p1 * s2 - p2 * s1) / (s2 - s1);
|
||||
//check for negative pressure and clamp to pmin for safety
|
||||
if (p2 <= pmin)
|
||||
{
|
||||
p2 = pmin;
|
||||
}
|
||||
//check if we've created an unrealistic pressure
|
||||
if (p2 >= pmax)
|
||||
{
|
||||
p2 = pmax; // swap values
|
||||
}
|
||||
p1 = p0;
|
||||
s1 = s2;
|
||||
}
|
||||
// check for failure to converge
|
||||
if (j >= NG_Cal.MAX_NUM_OF_ITERATIONS)
|
||||
{
|
||||
ptAGA10.argValue.lStatus = NG_Cal.MAX_NUM_OF_ITERATIONS_EXCEEDED;
|
||||
}
|
||||
//calc enthalpy at guessed P & current iter T
|
||||
h2 = this.H(ptAGA10, ptD) - h0;
|
||||
//calculate our proportional change
|
||||
delta1 = Math.abs(h1 - h2) / h0;
|
||||
// close enough?
|
||||
if (delta1 < tolerance && i > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
//revise our estimate to t2
|
||||
t0 = t2;
|
||||
t2 = (t1 * h2 - t2 * h1) / (h2 - h1);
|
||||
//check if we've created an unrealistic temperature
|
||||
if (t2 >= tmax)
|
||||
{
|
||||
t2 = tmax;
|
||||
}
|
||||
//revise t2, if necessary
|
||||
if (t2 <= tmin)
|
||||
{
|
||||
t2 = t0 + 10.0;
|
||||
ptAGA10.argValue.dTf = t2;
|
||||
ptD.argValue.Run(ptAGA10);
|
||||
h2 = this.H(ptAGA10, ptD) - h0;
|
||||
}
|
||||
t1 = t0;
|
||||
h1 = h2;
|
||||
}
|
||||
// check for failure to converge
|
||||
if (i >= NG_Cal.MAX_NUM_OF_ITERATIONS)
|
||||
{
|
||||
ptAGA10.argValue.lStatus = NG_Cal.MAX_NUM_OF_ITERATIONS_EXCEEDED;
|
||||
}
|
||||
} //HS_Mode()
|
||||
/**************************************************************************
|
||||
*Function:H()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT , Detail *
|
||||
*Returns:double
|
||||
*Purpose:real gas specific enthalpy
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
private double H(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10, com.ng.ngtools.tangible.RefObject<Detail> ptD)
|
||||
{
|
||||
double Hinc;
|
||||
double x;
|
||||
int i;
|
||||
//initialize integral
|
||||
Hinc = 0.0;
|
||||
//find ideal gas enthalpy
|
||||
ptAGA10.argValue.dHo = Ho(ptAGA10);
|
||||
//integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature
|
||||
for (i = 0; i < GK_points; i++)
|
||||
{
|
||||
//calculate 1st and 2nd partial derivatives of Z wrt T
|
||||
x = ptAGA10.argValue.dDf * (1.0 + GK_root[i]) / 2.0;
|
||||
ptD.argValue.zdetail(x);
|
||||
ptD.argValue.dZdT(x);
|
||||
ptD.argValue.d2ZdT2(x);
|
||||
Hinc += GK_weight[i] * ptD.argValue.ddZdT / x;
|
||||
if (i == 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
x = ptAGA10.argValue.dDf * (1.0 - GK_root[i]) / 2.0;
|
||||
ptD.argValue.zdetail(x);
|
||||
ptD.argValue.dZdT(x);
|
||||
ptD.argValue.d2ZdT2(x);
|
||||
Hinc += GK_weight[i] * ptD.argValue.ddZdT / x;
|
||||
}
|
||||
ptD.argValue.zdetail(ptAGA10.argValue.dDf);
|
||||
ptD.argValue.dZdT(ptAGA10.argValue.dDf);
|
||||
ptD.argValue.d2ZdT2(ptAGA10.argValue.dDf);
|
||||
// calculate specific enthalpy
|
||||
ptAGA10.argValue.dH = ptAGA10.argValue.dHo + 1000.0 * NG_Cal.RGAS * ptAGA10.argValue.dTf * (ptAGA10.argValue.dZf - 1.0 - ptAGA10.argValue.dTf * Hinc * 0.5 * ptAGA10.argValue.dDf) / ptAGA10.argValue.dMrx;
|
||||
return (ptAGA10.argValue.dH);
|
||||
} // H()
|
||||
/**************************************************************************
|
||||
*Function:S()
|
||||
*Arguments:ref AGA10.GasPropsSTRUCT , Detail *
|
||||
*Returns:double
|
||||
*Purpose:real gas specific entropy
|
||||
*Revisions:
|
||||
**************************************************************************/
|
||||
private double S(com.ng.ngtools.tangible.RefObject<NG_Cal.GasPropsSTRUCT> ptAGA10, com.ng.ngtools.tangible.RefObject<Detail> ptD)
|
||||
{
|
||||
double Sinc;
|
||||
double Smixing;
|
||||
double x;
|
||||
int i;
|
||||
//initialize integral
|
||||
Sinc = 0.0;
|
||||
//initialize entropy of mixing
|
||||
Smixing = 0.0;
|
||||
//integrate partial derivatives from D=0 to D=D, applying Gauss-Kronrod quadrature
|
||||
for (i = 0; i < GK_points; i++)
|
||||
{
|
||||
//calculate 1st and 2nd partial derivatives of Z wrt T
|
||||
x = ptAGA10.argValue.dDf * (1.0 + GK_root[i]) / 2.0;
|
||||
ptD.argValue.zdetail(x);
|
||||
ptD.argValue.dZdT(x);
|
||||
ptD.argValue.d2ZdT2(x);
|
||||
Sinc += GK_weight[i] * (ptD.argValue.dZ + ptAGA10.argValue.dTf * ptD.argValue.ddZdT - 1.0) / x;
|
||||
if (i == 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
x = ptAGA10.argValue.dDf * (1.0 - GK_root[i]) / 2.0;
|
||||
ptD.argValue.zdetail(x);
|
||||
ptD.argValue.dZdT(x);
|
||||
ptD.argValue.d2ZdT2(x);
|
||||
Sinc += GK_weight[i] * (ptD.argValue.dZ + ptAGA10.argValue.dTf * ptD.argValue.ddZdT - 1.0) / x;
|
||||
}
|
||||
//reset Z and partial deivatives dZdT and d2ZdT2
|
||||
ptD.argValue.zdetail(ptAGA10.argValue.dDf);
|
||||
ptD.argValue.dZdT(ptAGA10.argValue.dDf);
|
||||
ptD.argValue.d2ZdT2(ptAGA10.argValue.dDf);
|
||||
//find ideal gas entropy, but only if temperature or composition have changed
|
||||
if (ptAGA10.argValue.dTf != dTold || ptAGA10.argValue.dMrx != dMrxold)
|
||||
{
|
||||
dSi = So(ptAGA10);
|
||||
dTold = ptAGA10.argValue.dTf;
|
||||
dMrxold = ptAGA10.argValue.dMrx;
|
||||
}
|
||||
//calculate entropy of mixing
|
||||
for (i = 0; i < NG_Cal.NUMBEROFCOMPONENTS; i++)
|
||||
{
|
||||
if (ptAGA10.argValue.adMixture[i] != 0)
|
||||
{
|
||||
Smixing += ptAGA10.argValue.adMixture[i] * Math.log(ptAGA10.argValue.adMixture[i]);
|
||||
}
|
||||
}
|
||||
Smixing *= NG_Cal.RGAS;
|
||||
// calculate specific entropy
|
||||
ptAGA10.argValue.dS = dSi - Smixing - 1000.0 * NG_Cal.RGAS * (Math.log(ptAGA10.argValue.dPf / 101325.0) - Math.log(ptAGA10.argValue.dZf) + Sinc * 0.5 * ptAGA10.argValue.dDf) / ptAGA10.argValue.dMrx;
|
||||
return (ptAGA10.argValue.dS);
|
||||
} // S()
|
||||
}
|
403
src/main/java/com/ng/ngtools/modules/UnitConvert.java
Normal file
403
src/main/java/com/ng/ngtools/modules/UnitConvert.java
Normal file
@ -0,0 +1,403 @@
|
||||
package com.ng.ngtools.modules;
|
||||
|
||||
import com.ng.ngtools.tangible.FloatingPointToInteger;
|
||||
|
||||
public class UnitConvert
|
||||
{
|
||||
public final double Converter(String UnitName, double oldValue, int oldunit, int newunit, int Xsdws)
|
||||
{
|
||||
double returnValue = 0;
|
||||
//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
|
||||
//Dim strUnit() As String
|
||||
double[] dataUnit = new double[] {0};
|
||||
|
||||
//ReDim strUnit(UnitNum)
|
||||
//RereDim dataUnit(UnitNum)
|
||||
switch (UnitName)
|
||||
{
|
||||
case "tj":
|
||||
|
||||
dataUnit = new double[8];
|
||||
|
||||
|
||||
//strUnit(0) = "立方米(m3)"
|
||||
//strUnit(1) = "升(L, dm3)"
|
||||
//strUnit(2) = "立方厘米(cm3, ml, c.c)"
|
||||
//strUnit(3) = "立方英尺(ft3)"
|
||||
//strUnit(4) = "立方英寸(in3)"
|
||||
//strUnit(5) = "英加仑(UKgal)"
|
||||
//strUnit(6) = "美加仑(U.Sgal)"
|
||||
//strUnit(7) = "美油桶(USbbl)"
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 1000;
|
||||
dataUnit[2] = 1000000;
|
||||
dataUnit[3] = 35.3147;
|
||||
dataUnit[4] = 61023.7;
|
||||
dataUnit[5] = 219.969;
|
||||
dataUnit[6] = 264.172;
|
||||
dataUnit[7] = 6.28994;
|
||||
break;
|
||||
|
||||
case "zl":
|
||||
|
||||
//strUnit(0) = "千克(公斤)(kg)"
|
||||
//strUnit(1) = "克(g)"
|
||||
//strUnit(2) = "毫克(mg)"
|
||||
//strUnit(3) = "吨(t)"
|
||||
//strUnit(4) = "英吨(长吨)(UKton)"
|
||||
//strUnit(5) = "美吨(短吨)(U.Ston)"
|
||||
//strUnit(6) = "磅(lb)"
|
||||
//strUnit(7) = "盎司(oz)"
|
||||
dataUnit = new double[8]; //As Double
|
||||
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 1000;
|
||||
dataUnit[2] = 1000000;
|
||||
dataUnit[3] = 0.001;
|
||||
dataUnit[4] = 0.000984207;
|
||||
dataUnit[5] = 0.00110231;
|
||||
dataUnit[6] = 2.20462;
|
||||
dataUnit[7] = 35.274;
|
||||
break;
|
||||
case "rl":
|
||||
//strUnit(0) = "焦耳(J)"
|
||||
//strUnit(1) = "马力小时(Hp·h)"
|
||||
//strUnit(2) = "公斤力·米(kgf·m)"
|
||||
//strUnit(3) = "升·大气压(L·atm)"
|
||||
//strUnit(4) = "尔格(erg)"
|
||||
//strUnit(5) = "千卡(kacl)"
|
||||
//strUnit(6) = "千瓦小时(kW·h)"
|
||||
//strUnit(7) = "英马力小时(UKHp·h)"
|
||||
//strUnit(8) = "英尺·磅力(ft·lbf)"
|
||||
//strUnit(9) = "英热单位(BTU)"
|
||||
dataUnit = new double[10]; // As Double
|
||||
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 0.000000377672;
|
||||
dataUnit[2] = 0.101972;
|
||||
dataUnit[3] = 0.00986923;
|
||||
dataUnit[4] = 107;
|
||||
dataUnit[5] = 0.000238846;
|
||||
dataUnit[6] = 0.000000277778;
|
||||
dataUnit[7] = 0.000000372506;
|
||||
dataUnit[8] = 0.737562;
|
||||
dataUnit[9] = 0.000947813;
|
||||
break;
|
||||
|
||||
|
||||
case "nlll":
|
||||
//strUnit(0) = "兆焦/秒(MJ/s)"
|
||||
//strUnit(1) = "兆焦/小时(MJ/h)"
|
||||
//strUnit(2) = "兆焦/天(MJ/d)"
|
||||
//strUnit(3) = "千卡/秒(kcal/s)"
|
||||
//strUnit(4) = "千卡/小时(kcal/h)"
|
||||
//strUnit(5) = "英热单位/秒(BTU/s)"
|
||||
//strUnit(6) = "英热单位/小时(BTU/h)"
|
||||
|
||||
dataUnit = new double[7]; //As Double
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 3600;
|
||||
dataUnit[2] = 86400;
|
||||
dataUnit[3] = 238.846;
|
||||
dataUnit[4] = 859845.6;
|
||||
dataUnit[5] = 947.813;
|
||||
dataUnit[6] = 3412126.8;
|
||||
break;
|
||||
|
||||
case "zlll":
|
||||
|
||||
//strUnit(0) = "千克(公斤)/秒(kg/s)"
|
||||
//strUnit(1) = "千克(公斤)/分(kg/Min)"
|
||||
//strUnit(2) = "千克(公斤)/时(kg/h)"
|
||||
//strUnit(3) = "磅/秒(lb/s)"
|
||||
//strUnit(4) = "磅/分(lb/Min)"
|
||||
//strUnit(5) = "磅/时(lb/h)"
|
||||
//strUnit(6) = "吨/时(t/h)"
|
||||
//strUnit(7) = "英吨(长吨)/时(UKton/h)"
|
||||
//strUnit(8) = "美吨(短吨)/小时(U.Ston/h)"
|
||||
|
||||
dataUnit = new double[9]; //As Double
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 60;
|
||||
dataUnit[2] = 3600;
|
||||
dataUnit[3] = 2.20462;
|
||||
dataUnit[4] = 132.2772;
|
||||
dataUnit[5] = 7936.632;
|
||||
dataUnit[6] = 3.6;
|
||||
dataUnit[7] = 3.543145;
|
||||
dataUnit[8] = 3.968316;
|
||||
break;
|
||||
case "tjll":
|
||||
//strUnit(0) = "立方米/秒(m3/s)"
|
||||
//strUnit(1) = "万立方米/天(m3/d)"
|
||||
//strUnit(1) = "立方米/时(m3/h)"
|
||||
//strUnit(2) = "立方米/分(m3/Min)"
|
||||
//strUnit(3) = "升/时(L/h)"
|
||||
//strUnit(4) = "升/分(L/Min)"
|
||||
//strUnit(5) = "升/秒(L/s)"
|
||||
//strUnit(6) = "立方英尺/时(ft3/h)"
|
||||
//strUnit(7) = "立方英尺/分(ft3/Min)"
|
||||
//strUnit(8) = "立方英尺/秒(ft3/s)"
|
||||
//strUnit(9) = "立方英尺/秒(ft3/s)"
|
||||
//strUnit(10) = "立方英尺/天(ft3/d)"
|
||||
|
||||
//strUnit(11) = "英加仑/秒(UKgal/s)"
|
||||
//strUnit(12) = "美加仑/秒(U.Sgal/s)"
|
||||
//strUnit(13) = "美油桶/秒(USbbl/s)"
|
||||
|
||||
|
||||
dataUnit = new double[13]; //As Double
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 8.64;
|
||||
dataUnit[2] = 3600;
|
||||
dataUnit[3] = 60;
|
||||
dataUnit[4] = 3600000;
|
||||
dataUnit[5] = 60000;
|
||||
dataUnit[6] = 1000;
|
||||
dataUnit[7] = 127132.92;
|
||||
dataUnit[8] = 2118.882;
|
||||
dataUnit[8] = 0.0245240972222222;
|
||||
dataUnit[9] = 35.3147;
|
||||
dataUnit[10] = 219.969;
|
||||
dataUnit[11] = 264.172;
|
||||
dataUnit[12] = 6.28994;
|
||||
break;
|
||||
|
||||
|
||||
case "yl":
|
||||
//strUnit(0) = "帕(Pa)"
|
||||
//strUnit(1) = "千帕(kPa)"
|
||||
//strUnit(2) = "兆帕(Mpa)"
|
||||
//strUnit(3) = "标准大气压(atm)"
|
||||
//strUnit(4) = "毫巴(mbar)"
|
||||
//strUnit(5) = "巴(bar)"
|
||||
//strUnit(6) = "千克力/平方米(kgf/m2)"
|
||||
//strUnit(7) = "千克力/平方厘米(kgf/cm2)"
|
||||
//strUnit(8) = "毫米汞柱(mmHg)"
|
||||
//strUnit(9) = "毫米水柱4℃(mmH2O)"
|
||||
//strUnit(10) = "磅/平方英寸(psi)"
|
||||
|
||||
dataUnit = new double[11]; //As Double
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 0.001;
|
||||
dataUnit[2] = 0.000001;
|
||||
dataUnit[3] = 0.00000986923266716013;
|
||||
dataUnit[4] = 0.01;
|
||||
dataUnit[5] = 0.00001;
|
||||
dataUnit[6] = 0.101971621;
|
||||
dataUnit[7] = 0.0000101972;
|
||||
dataUnit[8] = 0.007500638;
|
||||
dataUnit[9] = 0.101972;
|
||||
dataUnit[10] = 0.000145038;
|
||||
break;
|
||||
|
||||
case "wd":
|
||||
switch (newunit)
|
||||
{
|
||||
case 0:
|
||||
switch (oldunit)
|
||||
{
|
||||
case 0:
|
||||
returnValue = oldValue;
|
||||
break;
|
||||
case 1: //K->℃
|
||||
returnValue = oldValue - 273.15;
|
||||
break;
|
||||
case 2: //F->℃
|
||||
returnValue = (oldValue - 32) / 1.8;
|
||||
break;
|
||||
case 3: //R->℃
|
||||
returnValue = oldValue / 1.8 - 273.15;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (oldunit)
|
||||
{
|
||||
case 0: //℃->K
|
||||
returnValue = oldValue + 273.15;
|
||||
break;
|
||||
case 1:
|
||||
returnValue = oldValue;
|
||||
break;
|
||||
case 2: //F->K
|
||||
returnValue = (oldValue - 32) / 1.8 + 273.15;
|
||||
break;
|
||||
case 3: //R->K
|
||||
returnValue = oldValue / 1.8;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (oldunit)
|
||||
{
|
||||
case 0: //C->F
|
||||
returnValue = oldValue * 1.8 + 32;
|
||||
break;
|
||||
case 1: //k->f
|
||||
returnValue = (oldValue - 273.15) * 1.8 + 32;
|
||||
break;
|
||||
case 2:
|
||||
returnValue = oldValue;
|
||||
break;
|
||||
case 3: //R->F
|
||||
returnValue = oldValue - 273.15 * 1.8 + 32;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch (oldunit)
|
||||
{
|
||||
case 0: //C->R
|
||||
returnValue = (oldValue + 273.15) * 1.8;
|
||||
break;
|
||||
case 1: //K->R
|
||||
returnValue = oldValue * 1.8;
|
||||
break;
|
||||
case 2: //F->R
|
||||
returnValue = (oldValue - 32) + 273.15 * 1.8;
|
||||
break;
|
||||
case 3:
|
||||
returnValue = oldValue;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return returnValue;
|
||||
case "cd":
|
||||
//米(m)
|
||||
//分米(dm)
|
||||
//厘米(cm)
|
||||
//毫米(mm)
|
||||
//英尺(ft)
|
||||
//英寸(in)
|
||||
//英里(mile)
|
||||
//英寻(fm)
|
||||
//海里(nmile)
|
||||
//埃(a)
|
||||
//码(yd)
|
||||
//密尔(mil)
|
||||
//杆<(rad)
|
||||
|
||||
dataUnit = new double[14]; //As Double
|
||||
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 10;
|
||||
dataUnit[2] = 100;
|
||||
dataUnit[3] = 1000;
|
||||
dataUnit[4] = 3.28038;
|
||||
dataUnit[5] = 39.3700787401575;
|
||||
dataUnit[6] = 0.001;
|
||||
dataUnit[7] = 0.000621504039776259;
|
||||
dataUnit[8] = 0.546746856205577;
|
||||
dataUnit[9] = 0.000539956803455;
|
||||
dataUnit[10] = 10000000000.0D;
|
||||
dataUnit[11] = 1.093613;
|
||||
dataUnit[12] = 39370.0787401575;
|
||||
dataUnit[13] = 0.198838781515947;
|
||||
break;
|
||||
|
||||
case "mj":
|
||||
|
||||
|
||||
//平方米m2
|
||||
//平方分米dm2
|
||||
//平方厘米cm2
|
||||
//平方毫米mm2
|
||||
//平方英尺ft2
|
||||
//平方英寸in2
|
||||
//平方公里km2
|
||||
//公顷ha
|
||||
//公亩are
|
||||
//英亩acre
|
||||
//平方英里sq -mile
|
||||
//平方码yd2
|
||||
|
||||
dataUnit = new double[12]; //As Double
|
||||
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 100;
|
||||
dataUnit[2] = 10000;
|
||||
dataUnit[3] = 1000000;
|
||||
dataUnit[4] = 10.7608929444;
|
||||
dataUnit[5] = 1550.0031;
|
||||
dataUnit[6] = 0.000001;
|
||||
dataUnit[7] = 0.0001;
|
||||
dataUnit[8] = 0.01;
|
||||
dataUnit[9] = 0.0002471;
|
||||
dataUnit[10] = 0.000000386102158;
|
||||
dataUnit[11] = 1.19599;
|
||||
break;
|
||||
//小时
|
||||
//分钟
|
||||
//天
|
||||
//秒
|
||||
|
||||
case "sj":
|
||||
dataUnit = new double[4]; //As Double
|
||||
|
||||
dataUnit[0] = 1;
|
||||
dataUnit[1] = 60;
|
||||
dataUnit[2] = 0.0416666666666667;
|
||||
dataUnit[3] = 3600;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case "sd":
|
||||
break;
|
||||
//米每秒
|
||||
//厘米每秒
|
||||
//
|
||||
}
|
||||
if (newunit == oldunit)
|
||||
{
|
||||
return oldValue;
|
||||
|
||||
}
|
||||
return SsWr(oldValue * dataUnit[newunit] / dataUnit[oldunit], Xsdws);
|
||||
|
||||
}
|
||||
|
||||
private double SsWr(double value, int weishu)
|
||||
{
|
||||
long tempValue = 0;
|
||||
double SorR = 0;
|
||||
try
|
||||
{
|
||||
tempValue = (long)(value * Math.pow(10, weishu));
|
||||
|
||||
SorR = FloatingPointToInteger.ToInt32((value * Math.pow(10, weishu) - tempValue) * 10);
|
||||
if (SorR >= 5)
|
||||
{
|
||||
tempValue++;
|
||||
}
|
||||
return tempValue / Math.pow(10, weishu);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.ng.ngtools.tangible;
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Copyright © 2007 - 2017 Tangible Software Solutions Inc.
|
||||
// This class can be used by anyone provided that the copyright notice remains intact.
|
||||
//
|
||||
// This class is used to convert System.Convert methods which convert from
|
||||
// floating point types to integral types.
|
||||
//----------------------------------------------------------------------------------------
|
||||
public class FloatingPointToInteger
|
||||
{
|
||||
public static byte ToSByte(double source)
|
||||
{
|
||||
byte floor = (byte)Math.floor(source);
|
||||
if (Math.abs(source - floor) == 0.5)
|
||||
{
|
||||
if (floor % 2 == 0)
|
||||
return floor;
|
||||
else
|
||||
return (byte)Math.ceil(source);
|
||||
}
|
||||
else if (Math.abs(source - floor) < 0.5)
|
||||
return floor;
|
||||
else
|
||||
return (byte)Math.ceil(source);
|
||||
}
|
||||
|
||||
public static short ToInt16(double source)
|
||||
{
|
||||
short floor = (short)Math.floor(source);
|
||||
if (Math.abs(source - floor) == 0.5)
|
||||
{
|
||||
if (floor % 2 == 0)
|
||||
return floor;
|
||||
else
|
||||
return (short)Math.ceil(source);
|
||||
}
|
||||
else if (Math.abs(source - floor) < 0.5)
|
||||
return floor;
|
||||
else
|
||||
return (short)Math.ceil(source);
|
||||
}
|
||||
|
||||
public static int ToInt32(double source)
|
||||
{
|
||||
int floor = (int)Math.floor(source);
|
||||
if (Math.abs(source - floor) == 0.5)
|
||||
{
|
||||
if (floor % 2 == 0)
|
||||
return floor;
|
||||
else
|
||||
return (int)Math.ceil(source);
|
||||
}
|
||||
else if (Math.abs(source - floor) < 0.5)
|
||||
return floor;
|
||||
else
|
||||
return (int)Math.ceil(source);
|
||||
}
|
||||
|
||||
public static long ToInt64(double source)
|
||||
{
|
||||
long floor = (long)Math.floor(source);
|
||||
if (Math.abs(source - floor) == 0.5)
|
||||
{
|
||||
if (floor % 2 == 0)
|
||||
return floor;
|
||||
else
|
||||
return (long)Math.ceil(source);
|
||||
}
|
||||
else if (Math.abs(source - floor) < 0.5)
|
||||
return floor;
|
||||
else
|
||||
return (long)Math.ceil(source);
|
||||
}
|
||||
}
|
16
src/main/java/com/ng/ngtools/tangible/RefObject.java
Normal file
16
src/main/java/com/ng/ngtools/tangible/RefObject.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.ng.ngtools.tangible;
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Copyright © 2007 - 2017 Tangible Software Solutions Inc.
|
||||
// This class can be used by anyone provided that the copyright notice remains intact.
|
||||
//
|
||||
// This class is used to replicate the ability to pass arguments by reference in Java.
|
||||
//----------------------------------------------------------------------------------------
|
||||
public class RefObject<T>
|
||||
{
|
||||
public T argValue;
|
||||
public RefObject(T refArg)
|
||||
{
|
||||
argValue = refArg;
|
||||
}
|
||||
}
|
3
src/main/resources/META-INF/MANIFEST.MF
Normal file
3
src/main/resources/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: com.ng.ngtools.NgApplication
|
||||
|
27
src/main/resources/application.yml
Normal file
27
src/main/resources/application.yml
Normal file
@ -0,0 +1,27 @@
|
||||
# 开发环境配置
|
||||
server:
|
||||
address: 0.0.0.0
|
||||
###配置https
|
||||
port: 8443
|
||||
#开启https,配置跟证书一一对应
|
||||
ssl:
|
||||
enabled: true
|
||||
#指定证书
|
||||
key-store: classpath:ngtools.cn.jks
|
||||
key-store-type: JKS
|
||||
#密码
|
||||
key-store-password: kvp09gai
|
||||
protocol: TLS
|
||||
|
||||
# key-alias: ngtools
|
||||
# key-store: classpath:ngtools.cn.pfx
|
||||
# key-store-type: PKCS12
|
||||
# key-store-password: 9tbr2ybr
|
||||
|
||||
|
||||
|
||||
servlet:
|
||||
context-path:
|
||||
|
||||
|
||||
myhttp-port: 8888
|
24
src/main/resources/log4j.properties
Normal file
24
src/main/resources/log4j.properties
Normal file
@ -0,0 +1,24 @@
|
||||
### ??###
|
||||
log4j.rootLogger = debug,stdout,D,E
|
||||
|
||||
### ???????? ###
|
||||
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target = System.out #???????????????? System.err?
|
||||
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
|
||||
|
||||
### ??DEBUG ????????=/home/duqi/logs/debug.log ###
|
||||
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.D.File = /home/duqi/logs/debug.log
|
||||
log4j.appender.D.Append = true
|
||||
log4j.appender.D.Threshold = DEBUG
|
||||
log4j.appender.D.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
|
||||
|
||||
### ??ERROR ????????=/home/admin/logs/error.log ###
|
||||
log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.E.File =/home/admin/logs/error.log
|
||||
log4j.appender.E.Append = true
|
||||
log4j.appender.E.Threshold = ERROR
|
||||
log4j.appender.E.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
|
BIN
src/main/resources/ngtools.cn.jks
Normal file
BIN
src/main/resources/ngtools.cn.jks
Normal file
Binary file not shown.
16
src/main/resources/rebel.xml
Normal file
16
src/main/resources/rebel.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
|
||||
Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
|
||||
-->
|
||||
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
|
||||
|
||||
<id>ngtools</id>
|
||||
|
||||
<classpath>
|
||||
<dir name="E:/MyDocuments/Documents/project/java/ng/target/classes">
|
||||
</dir>
|
||||
</classpath>
|
||||
|
||||
</application>
|
6
src/main/resources/static/index.html
Normal file
6
src/main/resources/static/index.html
Normal file
@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>hello word!!!</h1>
|
||||
<p>this is a html page</p>
|
||||
</body>
|
||||
</html>
|
13
src/test/java/com/ng/ngtools/NgApplicationTests.java
Normal file
13
src/test/java/com/ng/ngtools/NgApplicationTests.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.ng.ngtools;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class NgApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user