In [9]:

```
import math
# given data
Gascook=5*0.227 # gas required for cooking in m^3/day
Gaslight=0.126*2*3 # gas required for lighting in m^3/day
Totalgasreq=Gascook+Gaslight # in m^3/day
gasperday=0.34*0.18*7 # in m^3/day
n=1+Totalgasreq/gasperday # no. of cows
print "The number of cows is ",int(n)
cowfeed=7*n # in kg
slurry=cowfeed*2.0/1090 # in m^3
totalslurry=50.0*slurry # in m^3
reqvolume=totalslurry/0.9
print "The total volume of digester is ",round(reqvolume,2),"m^3"
```

In [8]:

```
import math
# given data
Gaslight=10*0.227*4 # gas required for lighting in m^3/day
Eleccomp=10*250*6*60*60/1000000.0 # electrical energy required by computers in MJ
effith=0.25 # thermal efficieny
efficonv=0.80 # conversion efficiency
Heat=23.0 # heating value of biogas in MJ/m^3
rho=1090.0 # slurry density in kg/m^3
Engineinput=Eleccomp/(effith*efficonv)
energypump=746*2*2*60*60/1000000.0 # mechanical energy required for pumping in MJ
themalinput=energypump/effith # required thermal input in MJ
totalinput=themalinput+Engineinput # total thermal input required by engine
Volreq=totalinput/Heat # volume required per day in m^3/day
Totalrq=Volreq+Gaslight # total gas required in m^3 /day
n=Totalrq/(7*0.18*0.34) # solid mass is 18% and n is number of cows required
n=round(n)
print "The number of cows is",n
feed=7*n # daily feed in kg
slurry=2*feed # in kg
volslurry=slurry/rho # volume of slurry added per day in m^3
totalvol=50*volslurry/0.9 # total volume for 50 days in m^3 when 90 % is occupied by slurry
print "The size of biogas plant is ",round(totalvol,2),"m^3"
```

In [11]:

```
import math
# given data
Voldaily=1200 # daily production in m^3/day
prodrate=Voldaily/24.0 # gas production rate per hour
consrate=Voldaily/6.0 #gas consumtion rate per hour
Vg1=(consrate-prodrate)*2 # gas holder size required for 2 hours in litres
Vg2=prodrate*9 # gas holder size for 9 hours without consumption in litres
if Vg1>Vg2:
Vgmax=Vg1
else:
Vgmax=Vg2
Vg=Vgmax*1.25 # required gas holder with 25 % safety margin in litres
print "required gas holder size is ",Vg,"litres"
Capacity=Vg/Voldaily # required gas holder capacity
print "required gas holder capacity is ",round(Capacity*100,2),"%"
```

In [20]:

```
import math
# given data
drymattrprd=2 # dry matter produced in kg/day/cow
gasyield=0.22 # biogas yield in m^3 /kg
drymttr=18/100.0 # dry matter in cowdung
rho=1090 # slurry density in kg/m^3
effibrnr=0.6 # burner efficiency
Heat=23.0 # heating value of biogas in MJ/m^3
dungprd=drymattrprd*2/0.18 # dung produce in kg/day by 2 cows
slurry=2*dungprd # slurry produce in kg/day
volslurry=slurry/rho # volume of slurry in m^3
totalslurry=30*volslurry # for 30 days slurry in m^3
digestersize=totalslurry/0.85 # in m^3
print "the volume of digester is ",round(digestersize,2),"m^3"
gasprd=drymattrprd*2*gasyield # gas produced in m^3/day
Energytherm=gasprd*Heat*effibrnr # total thermal energy available in MJ/day
thermalpower=Energytherm*1000000/(24*60*60) # in watts
print "total thermal power is ",round(thermalpower,3),"W"
```