Skip to content

Instantly share code, notes, and snippets.

@NetoDevel

NetoDevel/Passo 4.5

Created Dec 29, 2015
Embed
What would you like to do?
/**
* Cálculo de B(x,t)
*/
System.out.println("\n***************************************************");
System.out.println("******************PASSO 4.5 Cálculo de B(x,t)******");
System.out.println("***************************************************\n");
BigDecimal Bxt = BigDecimal.ZERO;
BigDecimal x = BigDecimal.ZERO;
BigDecimal t = new BigDecimal("365").setScale(30, RoundingMode.HALF_EVEN);
/**
* Convertendo valor de v para m/d
*/
BigDecimal Vmd = v.multiply(new BigDecimal(Math.pow(10d, -2d))).setScale(30, RoundingMode.HALF_EVEN);
System.out.println("Valor de Vmd (1,96E-03): " + nb.format(Vmd));
/**
* convertendo valor de W para m/d
*/
BigDecimal Wmd = W.divide(new BigDecimal("100"), MathContext.DECIMAL128).setScale(30, RoundingMode.HALF_EVEN);
System.out.println("Valor de Wmd (2,39E-03): " + nb.format(Wmd));
/**
* Convertendo DX para m³/d
*/
BigDecimal Dxm3d = Dx.divide(new BigDecimal("10000")).setScale(30, RoundingMode.HALF_EVEN);
System.out.println("Valor de Dxm3d (3,99E-04): " + nb.format(Dxm3d));
System.out.println("Valor de R (2,79E+00): " + nb.format(R));
while (x.compareTo(Xm) <= 0) {
/**
* Cálculo do Primeiro Termo
*/
BigDecimal primeiroTermo = (Vmd.subtract(Wmd).multiply(x)).divide(Dxm3d.multiply(new BigDecimal(2d)), 20, RoundingMode.HALF_UP);
System.out.println("valor do primeiro termo: " + nb.format(primeiroTermo));
/**
* Cálculo do segundoTermo
*/
//R.x - w.t
BigDecimal dividendo = R.multiply(x).subtract(Wmd.multiply(t));
BigDecimal dois = new BigDecimal("2").setScale(20);
//2 . (D.R.t) ^ 1/2
BigDecimal divisor = new BigDecimal(Math.sqrt(Dxm3d.multiply(R).multiply(t).doubleValue())).multiply(dois);
BigDecimal segundoTermo = dividendo.divide(divisor, MathContext.DECIMAL128).setScale(30, RoundingMode.HALF_EVEN);
System.out.println("valor do segundo termo (-0,685292516): " + segundoTermo.setScale(9, RoundingMode.HALF_EVEN));
/**
* Cálculo do terceiroTermo
*/
BigDecimal terceiroTermo = (Vmd.add(Wmd).multiply(x)).divide(Dxm3d.multiply(new BigDecimal(2d)),20,RoundingMode.HALF_EVEN);
System.out.println("valor do terceiro termo (0,00E+00): " + nb.format(terceiroTermo));
/**
* Cálculo do quartoTermo
*/
BigDecimal quartoTermo = (R.multiply(x).add(Wmd.multiply(t)).divide((bigSqrt(Dxm3d.multiply(R).multiply(t)).multiply(dois)), MathContext.DECIMAL128).setScale(30, RoundingMode.HALF_EVEN));
System.out.println("valor do quartoTermo termo (0,685292516):" + quartoTermo.setScale(9, RoundingMode.HALF_EVEN));
BigDecimal divisao = new BigDecimal(1d/2d);
BigDecimal BxtFinal = (divisao.multiply(new BigDecimal(Math.exp(primeiroTermo.doubleValue()))).
multiply(new BigDecimal(Erf.erfc(segundoTermo.doubleValue()))).add((divisao)
.multiply(new BigDecimal(Math.exp(terceiroTermo.doubleValue())))
.multiply(new BigDecimal(Erf.erfc(quartoTermo.doubleValue())))));
System.out.println("Valor total de Bxt em BigDecimal: " + nb.format(BxtFinal));
x = x.add(new BigDecimal("0.8"));
System.out.println("==> Valor de x : " + x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment