java - 在java中获取距离大坝 "Event"的天数

标签 java math formula

我在制定公式来计算大坝排空或填满所需的天数时遇到了问题。这一切都在一个名为 Dam 的公共(public)类中进行。

基本上我有:

int capacity = 3538000;  // acreFT
int storage = 1796250;   // acreFT
int inflowRate = 1050;   // cubic-FT/sec
int outflowRate = 2530;  // cubic-FT/sec

然后我创建一个 if-else 语句,内容如下:

if(inflow > outflow)
{
     //formula here
}
else if (outflow > inflow)
{
     //formula here
}
else
{
     return -1; // if dam inflow/outflow is equal basically, "holding."
}

我该如何处理这里的公式?如果我从以下开始:

if(outflow > inflow)
{
     int data = outflow - inflow; // still in cubic-ft per sec
     // convert data to acresFT? using some sort of conversion variable?
     // then using new variable for the converted data * storage..?
     // then finally times by second in a day (86400 seconds, another variable established at the top of my program.)
}

这可能很难读,但我不想在这里上传整个文件。

最佳答案

我将你的变量的含义如下

capacity as the total volume of water it can hold
storage as the total volume of water it currently holds
inflow as volume of water flowing into the dam per second
outflow as volume of water flowing out of the dam per second 

int flow_rate_difference = 0 ;
Long dam_fill_seconds = 0;
Long dam_empty_seconds = 0;

if(inflow > outflow)
{
     //we have to calculate the amount of seconds it will take to fill the dam
     // 1 acre foot = 43560.0004435. I am taking 43560 plz use full value if you require more accuracy 
     // conversion taken from http://www.convertunits.com/from/cubic+foot/to/acre+foot

     // total capacity 3538000acrefoot
     // current capacity = total capacity - stored capacity ie (3538000-1796250) acrefoot
     // current capacity in cubic foot  (3538000-1796250)*43560
     // at the same second water is flowing into and out of dam . but if inflow is higher then that difference we have to calculate

     flow_rate_difference = inflowRate - outflowRate;
     // total sec required to fill dam is current capacity / flow_rate_difference 
     dam_fill_seconds = (3538000-1796250)*43560/flow_rate_difference ;

}
if (outflow > inflow )
{
    //time for dam to be empty

     flow_rate_difference =  outflowRate-inflowRate;
     //here we just need to take stored capacity 

     dam_empty_seconds = storage*43560/flow_rate_difference;



}

关于java - 在java中获取距离大坝 "Event"的天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30230369/

相关文章:

Excel 在行内排列列

java - 面板/按钮和重新绘制令人头痛

java - Java 8 的构造函数引用的实际应用?

c++ - 计算折扣适用价格(30%、20% 和 15% 的折扣)

c++ - GLM - 方向矩阵正在创建行主矩阵而不是列主矩阵?

formula - 放大 Mandelbrot 时计算动态迭代值

rotation - Libgdx 两点度数计算

java - 从 Java 中的 URL 读取 JSON 的最简单方法

java - 对 Grails/Groovy 内存泄漏进行故障排除?

java - Math.cos() & Math.sin() 如何使用?