-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path58_computef.jl
51 lines (41 loc) · 1.31 KB
/
58_computef.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using DelimitedFiles
function computef(CP0, CQ0, k2, km2, time)
data = readdlm("55_cineti.jl")
CAexp = data[:, 2]
CBexp = data[:, 3]
return CAexp, CBexp
function simulation(CP0, CQ0, k2, km2, time)
dt = 1.e-1
nsteps = Int64(time / dt)
t = Vector{Float64}(undef, nsteps)
CP = Vector{Float64}(undef, nsteps)
CQ = Vector{Float64}(undef, nsteps)
CP[1] = CP0
CQ[1] = CQ0
t[1] = 0.0
for i in 2:nsteps
CP[i] = CP[i-1] - k2 * CP[i-1] * dt + km2 * CQ[i-1] * dt
CQ[i] = CP0 + CQ0 - CP[i]
t[i] = t[i-1] + dt
end
return t, CP, CQ
end
function f(CP, CAexp)
f_val = 0.0
for i in 1:length(CAexp)
f_val += (CAexp[i] - P[i])^2
end
return f_val
end
# Leitura dos dados experimentais
CAexp, CBexp = dados_experimentais(dados_filename)
# Avaliar a similaridade
similaridade = f(CP, CAexp)
return similaridade
end
# Parâmetros iniciais para a simulação
CP0, CQ0, k2, km2, time = 10.0, 50.0, 0.003, 0.006, 100.0
# Chamar a função computef
similaridade_result = computef(CP0, CQ0, k2, km2, time)
# Exibir a similaridade
println("Similaridade entre os resultados simulados e experimentais: ", similaridade_result)