0% found this document useful (0 votes)
12 views

BC Envelope v3

This document defines functions for calculating the economic reserves of a block model using the floating cone method. It imports necessary libraries, defines functions for selecting blocks within footprints, copying block data, calculating block column attributes, NPV, and economic reserves. It then loads a block model, defines parameters, and runs the economic reserves calculation in a loop over multiple vertical levels. Finally it outputs results and runtime statistics.

Uploaded by

vadderex
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

BC Envelope v3

This document defines functions for calculating the economic reserves of a block model using the floating cone method. It imports necessary libraries, defines functions for selecting blocks within footprints, copying block data, calculating block column attributes, NPV, and economic reserves. It then loads a block model, defines parameters, and runs the economic reserves calculation in a loop over multiple vertical levels. Finally it outputs results and runtime statistics.

Uploaded by

vadderex
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

########### CARGAR LIBRERIAS ###########

import pandas as pd
from math import ceil
from math import floor
from time import time

########### DEFINIR FUNCIONES ###########

def bloques_footprint(mb,nv_min,ac_max,PED):
aa=mb[(mb["z"]>=nv_min)&(mb["z"]<=nv_min+ceil((2-(PED/100))*ac_max))]
aa.reset_index(drop=True,inplace=True)
return aa

def copia_bfp(bfp):
a=pd.DataFrame({"x":[],
"y":[],
"z":[],
"id":[],
"ton":[],
"ley":[],
"Bi":[]})
for i in range(len(bfp)):
fila={"x":bfp.at[i,"x"],
"y":bfp.at[i,"y"],
"z":bfp.at[i,"z"],
"id":int(bfp.at[i,"id"]),
"ton":bfp.at[i,"ton"],
"ley":bfp.at[i,"ley"],
"Bi":bfp.at[i,"Bi"]}
a=a.append(fila,ignore_index=True)
a.reset_index(drop=True,inplace=True)
return a

def bloques_columna(BFP,cx,cy):
b=BFP[(BFP["x"]==cx)&(BFP["y"]==cy)]
b.reset_index(drop=True,inplace=True)
return b.sort_values("z",ignore_index=True)

def altura_columna(bc,dz,ac_max):
hc_1=bc[bc["ley"]>0]["z"].max()-bc["z"].min()+dz
hc_2=floor(ac_max/dz)*dz
if hc_1<hc_2:
c=hc_1
else:
c=hc_2
return c

def VPN(bc,ti,tm,cd):
p=1
n_b=0
for n in range(len(bc)):
if n==0:
bc.loc[n,"VPNi"]=bc.at[n,"Bi"]/((1+(ti/100))**p)-cd
else:
bc.loc[n,"VPNi"]=bc.at[n,"Bi"]/((1+(ti/100))**p)
n_b+=1
if n_b%tm==0:
p+=1
return bc

def reservas_economicas(bfp,cd,ac_max,ac_min):
#############################################
def bloques_columna(BFP,cx,cy):
b=BFP[(BFP["x"]==cx)&(BFP["y"]==cy)]
b.reset_index(drop=True,inplace=True)
return b.sort_values("z",ignore_index=True)
#############################################

bfp["v_acum"]=0
bfp["FP"]=0
bfp_cmin=[bfp["x"].min(),bfp["y"].min(),bfp["z"].min()] #coord. (x,y) min. del
nivel
bfp_cmax=[bfp["x"].max(),bfp["y"].max(),bfp["z"].max()] #coord. (x,y) max. del
nivel
cx=bfp_cmin[0]
for p in range(int((bfp_cmax[0]-bfp_cmin[0]+dx)/dx)):
cy=bfp_cmin[1]
for q in range(int((bfp_cmax[1]-bfp_cmin[1]+dy)/dy)):
bc=bloques_columna(bfp,cx,cy)
for r in range(int((bfp_cmax[2]-bfp_cmin[2]+dz)/dz)):
if r==0:
bc.at[r,"v_acum"]=bc.at[r,"VPNi"]
else:
bc.at[r,"v_acum"]=bc.at[r-1,"v_acum"]+bc.at[r,"VPNi"]

ac_econ=bc.at[bc.query("v_acum=={}".format(bc["v_acum"].max())).index.tolist()
[0],"z"]-bfp_cmin[2]+dz
if ac_econ<=ac_max and bc["v_acum"].max()>=0 and ac_econ>=ac_min:
for s in
range(1+int(bc.query("v_acum=={}".format(bc["v_acum"].max())).index.tolist()[0])):
bc.at[s,"FP"]=1
elif ac_econ>ac_max and bc["v_acum"].max()>=0:
VPN_max=bc.at[bc.query("z=={}".format(bfp_cmin[2]+ac_max-
dz)).index.tolist()[0],"v_acum"]
if VPN_max>=0:
for s in
range(1+int(bc.query("z=={}".format(bfp_cmin[2]+ac_max-dz)).index.tolist()[0])):
bc.at[s,"FP"]=1
elif ac_econ<ac_min and bc["v_acum"].max()>=0:
VPN_max=bc.at[bc.query("z=={}".format(bfp_cmin[2]+ac_min-
dz)).index.tolist()[0],"v_acum"]
if VPN_max>=0:
for s in
range(1+int(bc.query("z=={}".format(bfp_cmin[2]+ac_min-dz)).index.tolist()[0])):
bc.at[s,"FP"]=1
for t in range(len(bc)):
bfp.loc[bfp.id==bc.at[t,"id"],"FP"]=bc.at[t,"FP"]
bfp.loc[bfp.id==bc.at[t,"id"],"v_acum"]=bc.at[t,"v_acum"]

cy+=dy
cx+=dx
return bfp
###########CARGAR MODELO DE BLOQUES###########

mb=pd.read_csv(r"C:\Users\paent\OneDrive\Escritorio\1S 2023 UDA\MIN185101


Preparacion y ev. de proyectos\4.2 proyecto y antecedentes\Antecedentes 1S2023\
ilubaya_XL.txt",sep="\t")

########### DEFINIR PARAMETROS ###########

#parametros geomecanicos
ac_max=15
ac_min=5
PED=80

#parametros para mb
dx,dy,dz=1,1,1

#parametros economicos
ti=12
tm=8
cd=2600000

########### INICIAR CALCULO DE ENVOLVENTE ###########

nv_min=mb[mb["ley"]>0]["z"].min()
nv_max=mb["z"].max()-ac_max
n_nv=(nv_max-nv_min+dz)/dz

acum_nv=pd.DataFrame({"nivel":[],
"n bloques":[],
"ton total":[],
"ley media":[],
"valor total":[]})

t3=time()
for i in range(int(n_nv)):
t1=time()

bfpp=bloques_footprint(mb,nv_min,ac_max,PED)
bfp=copia_bfp(bfpp)
bfp["VPNi"]=0
bfp_cmin=[bfp["x"].min(),bfp["y"].min()]
bfp_cmax=[bfp["x"].max(),bfp["y"].max()]
cx=bfp_cmin[0]
for p in range(int((bfp_cmax[0]-bfp_cmin[0]+dx)/dx)):
cy=bfp_cmin[1]
for q in range(int((bfp_cmax[1]-bfp_cmin[1]+dy)/dy)):
bc=bloques_columna(bfp,cx,cy)
vpn=VPN(bc,ti,tm,cd)
for r in range(len(bc)):
bfp.loc[bfp.id==vpn.at[r,"id"],"VPNi"]=vpn.at[r,"VPNi"]
cy+=dy
cx+=dx

re=reservas_economicas(bfp,cd,ac_max,ac_min)
re["fino"]=re["ton"]*(re["ley"]/100)

fila={"nivel":nv_min,
"n bloques":len(re[(re["FP"]==1)]),
"ton total":re[(re["FP"]==1)]["ton"].sum(),
"ley media":100*re[(re["FP"]==1)]["fino"].sum()/re[(re["FP"]==1)]
["ton"].sum(),
"valor total":re[(re["FP"]==1)]["VPNi"].sum()}
acum_nv=acum_nv.append(fila,ignore_index=True)

re.drop(["id","v_acum"],axis="columns",inplace=True)
re=re[["x","y","z","ton","ley","Bi","VPNi","FP"]]
re.to_csv(r"envelope_BC_nv{}.txt".format(nv_min),index=False,sep="\t")

t2=time()
print("nivel:{} | n° bloques:{} | tiempo:{}s".format(nv_min,len(bfp),round(t2-
t1,2)))
nv_min+=dz

acum_nv.to_csv(r"report_(PCBC).txt",index=False,sep="\t")
t4=time()
print("n° niveles:{} | tiempo total:{}min".format(n_nv,round((t4-t3)/60,2)))

You might also like