Revision | 22cc1e99ceb6fd3dc01ac219fb45f744a359588d (tree) |
---|---|
Zeit | 2008-08-12 00:48:43 |
Autor | iselllo |
Commiter | iselllo |
I fixed a bug in the expression of the kernel (the mass of an aggregate
is NOT equal to the volume, but rather to the number of monomers it
consists of since I am working in units where m_1=1).
FIX THIS BUG also in the code for smoluchowski equation used to evolve
an initially monodisperse aerosol.
I also now calculate the kernel both with <n_i><n_j> and with <n_in_j>.
@@ -6,7 +6,7 @@ | ||
6 | 6 | |
7 | 7 | time_red=p.load("../1/time_red.dat") #time I used when comparing the snapshots |
8 | 8 | |
9 | -n_dir=8 #number of different directories where I will be reading the data from | |
9 | +n_dir=10 #number of different directories where I will be reading the data from | |
10 | 10 | |
11 | 11 | dir_list=s.arange(n_dir)+1 |
12 | 12 |
@@ -20,11 +20,11 @@ | ||
20 | 20 | print "the snapshot time series is, ", time_red |
21 | 21 | |
22 | 22 | |
23 | -N_mon=5000. #initial number of monomers | |
23 | +N_mon_tot=5000. #initial number of monomers | |
24 | 24 | |
25 | 25 | rho=0.01 |
26 | 26 | |
27 | -box_vol=N_mon/rho | |
27 | +box_vol=N_mon_tot/rho | |
28 | 28 | |
29 | 29 | |
30 | 30 | by=2 |
@@ -44,14 +44,21 @@ | ||
44 | 44 | |
45 | 45 | n_j=s.zeros((n_dir,len(my_selection))) |
46 | 46 | |
47 | +###################### | |
47 | 48 | |
49 | +n_in_j_nonlinear=s.zeros((n_dir,len(my_selection))) # this array and the one below will be used to calculate <n_in_j> which is NOT <n_i><n_j>. | |
50 | + | |
51 | + | |
52 | +n_in_j_nonlinear_aver=s.zeros(len(my_selection)) | |
53 | + | |
54 | +################ | |
48 | 55 | n_i_aver=s.zeros(len(my_selection)) |
49 | 56 | n_j_aver=s.zeros(len(my_selection)) |
50 | 57 | |
51 | 58 | |
52 | 59 | sel_ker=s.arange(2) |
53 | -sel_ker[0]=1 #NB: these are ORDERED collisions: I can evaluate k_ij for i<j ONLY!!!! | |
54 | -sel_ker[1]=20 | |
60 | +sel_ker[0]=3 #NB: these are ORDERED collisions: I can evaluate k_ij for i<j ONLY!!!! | |
61 | +sel_ker[1]=4 | |
55 | 62 | |
56 | 63 | |
57 | 64 | sel_ker=sel_ker*1. #to get a floating point array |
@@ -134,6 +141,7 @@ | ||
134 | 141 | |
135 | 142 | n_i[m,i]=len(s.where(size_dist==sel_ker[0])[0]) |
136 | 143 | n_j[m,i]=len(s.where(size_dist==sel_ker[1])[0]) |
144 | + n_in_j_nonlinear[m,i]=n_i[m,i]*n_j[m,i] | |
137 | 145 | |
138 | 146 | #NB: the definition of n_i and n_j is well-posed even if NO collision involving them took place. |
139 | 147 |
@@ -146,6 +154,8 @@ | ||
146 | 154 | cluster_name=cluster_name+extension |
147 | 155 | cluster_name=dir_name+cluster_name |
148 | 156 | |
157 | + #print "cluster_name is, ", cluster_name | |
158 | + | |
149 | 159 | recorded_collisions=p.load(cluster_name) |
150 | 160 | |
151 | 161 |
@@ -219,6 +229,9 @@ | ||
219 | 229 | n_i_aver=n_i.mean(axis=0) #NO ambiguity about these averages; no problem if either n_i or n_j is zero. |
220 | 230 | n_j_aver=n_j.mean(axis=0) |
221 | 231 | |
232 | +n_in_j_nonlinear_aver=n_in_j_nonlinear.mean(axis=0) | |
233 | + | |
234 | +n_in_j_nonlinear_aver=n_in_j_nonlinear_aver/box_vol/box_vol #!!!!! careful with the normalization!! | |
222 | 235 | |
223 | 236 | |
224 | 237 | number_coll_aver=number_coll.mean(axis=0) |
@@ -413,14 +426,71 @@ | ||
413 | 426 | |
414 | 427 | print "coll_dens is, ", coll_dens |
415 | 428 | |
429 | + | |
430 | + | |
431 | +######## VERY Careful!!!! n_i_nj is now defined as <n_i><n_j> NOT as <n_in_j>. | |
432 | + | |
416 | 433 | n_in_j=n_i_aver/box_vol*n_j_aver/box_vol |
417 | 434 | |
418 | 435 | print "n_in_j is, ", n_in_j |
419 | 436 | |
420 | 437 | fitted_kernel=residuals_eval(coll_dens, n_in_j, k_ij_inf, k_ij_sup, n_steps) |
421 | 438 | |
422 | -print "fitted_kernel is, ", fitted_kernel[0] | |
439 | +if (sel_ker[0]!=sel_ker[1]): | |
423 | 440 | |
441 | + result=list(fitted_kernel[0]) | |
442 | + result=s.asarray(result) | |
443 | + result=result/2. | |
444 | +elif (sel_ker[0]==sel_ker[1]): | |
445 | + | |
446 | + result=list(fitted_kernel[0]) | |
447 | + result=s.asarray(result) | |
448 | +# result=result/2. | |
449 | + | |
450 | + | |
451 | + | |
452 | +print "fitted_kernel is, ", result | |
453 | + | |
454 | +#print "fitted_kernel is, ", fitted_kernel[0] | |
455 | + | |
456 | + | |
457 | +fitted_kernel_nonlinear=residuals_eval(coll_dens, n_in_j_nonlinear_aver, k_ij_inf, k_ij_sup, n_steps) | |
458 | + | |
459 | +if (sel_ker[0]!=sel_ker[1]): | |
460 | + result=list(fitted_kernel_nonlinear[0]) | |
461 | + result=s.asarray(result) | |
462 | + | |
463 | + result=result/2. | |
464 | + | |
465 | +elif (sel_ker[0]==sel_ker[1]): | |
466 | + | |
467 | + result=list(fitted_kernel_nonlinear[0]) | |
468 | + result=s.asarray(result) | |
469 | + | |
470 | + | |
471 | +print "fitted_kernel is [nonlinear average], ", result | |
472 | + | |
473 | +p.save("nonlin_aver_n_i_nj.dat",n_in_j_nonlinear_aver ) | |
474 | +p.save("lin_aver_n_i_nj.dat",n_in_j ) | |
475 | + | |
476 | + | |
477 | + | |
478 | + | |
479 | +fig = p.figure() | |
480 | +axes = fig.gca() | |
481 | + | |
482 | + | |
483 | +axes.plot(time_coll,n_in_j, "bo", label="<n_i><n_j>") | |
484 | +axes.plot(time_coll, n_in_j_nonlinear_aver, "k^", label="<n_in_j>") | |
485 | +p.xlabel('Time') | |
486 | +p.ylabel('Number of collisions') | |
487 | +#p.title("Evolution Mean-free path") | |
488 | +p.grid(True) | |
489 | +cluster_name="non_linear_vs_linear_n_in_j.pdf" | |
490 | +axes.legend() | |
491 | +p.savefig(cluster_name) | |
492 | + | |
493 | +p.clf() | |
424 | 494 | |
425 | 495 | |
426 | 496 |
@@ -463,6 +533,18 @@ | ||
463 | 533 | |
464 | 534 | p.clf() |
465 | 535 | |
536 | + | |
537 | + | |
538 | + | |
539 | + | |
540 | +p.save("time_coll.dat",time_coll) | |
541 | + | |
542 | +p.save("k_ij.dat", fitted_kernel[0]) | |
543 | + | |
544 | +p.save("coll_ij_density.dat", coll_dens) | |
545 | + | |
546 | +p.save("fitted_coll_density.dat",fitted_kernel[0]*n_in_j) | |
547 | + | |
466 | 548 | #Now I do as above but I specify a time-span |
467 | 549 | |
468 | 550 | time_inf=0. |
@@ -473,9 +555,21 @@ | ||
473 | 555 | |
474 | 556 | fitted_kernel=residuals_eval(coll_dens[time_span], n_in_j[time_span], k_ij_inf, k_ij_sup, n_steps) |
475 | 557 | |
476 | -print "fitted_kernel is, ", fitted_kernel[0] | |
558 | + | |
559 | +if (sel_ker[0]!=sel_ker[1]): | |
560 | + | |
561 | + result=list(fitted_kernel[0]) | |
562 | + result=s.asarray(result) | |
563 | + | |
564 | + result=result/2. | |
565 | + | |
566 | +elif (sel_ker[0]==sel_ker[1]): | |
567 | + | |
568 | + result=list(fitted_kernel[0]) | |
569 | + result=s.asarray(result) | |
477 | 570 | |
478 | 571 | |
572 | +print "fitted_kernel [on time span] is, ", result | |
479 | 573 | |
480 | 574 | |
481 | 575 | fig = p.figure() |
@@ -517,4 +611,260 @@ | ||
517 | 611 | |
518 | 612 | p.save("residuals_span.dat", fitted_kernel[1]) |
519 | 613 | |
614 | +############################################################################################################################ | |
615 | +############################################################################################################################ | |
616 | +############################################################################################################################ | |
617 | +############################################################################################################################ | |
618 | + | |
619 | +#now I compare the results between the calculated kernel elements, the smoluchowski kernel and "our" kernel | |
620 | + | |
621 | +#First some parameters of the system | |
622 | + | |
623 | + | |
624 | + | |
625 | +beta=1. #cluster/monomer 1/tau | |
626 | +k_B=1. #in these units | |
627 | +T_0=0.5 #temperature of the system | |
628 | +m_mon=1. #monomer mass in these units | |
629 | +sigma=1. #monomer diameter | |
630 | +mu=(m_mon*beta)/(3.*s.pi*sigma) # fluid viscosity | |
631 | + | |
632 | + | |
633 | + | |
634 | +r_mon=0.5 | |
635 | + | |
636 | +v_mono=4./3.*s.pi*r_mon**3. | |
637 | + | |
638 | +print "the monodisperse volume is, ", v_mono | |
639 | + | |
640 | +## x=s.logspace(s.log10(v_mono), s.log10(v_mono*4500.),400) # volume grid | |
641 | + | |
642 | +## n_mon=x/v_mono #volume of solids expressed in terms of number of monomers | |
643 | + | |
644 | + | |
645 | + | |
646 | + | |
647 | + | |
648 | + | |
649 | + | |
650 | +n_mon=sel_ker*1. #to have a floating point array. | |
651 | + | |
652 | +m=n_mon # since I set the mass of a single monomer equal to 1, then the mass of a cluster is the same as the number of monomers it consists of. | |
653 | + | |
654 | +print "n_mon is, ", n_mon | |
655 | + | |
656 | + | |
657 | +x=n_mon*v_mono | |
658 | + | |
659 | + | |
660 | +threshold=15. # I define the threshold between small and large clusters, to be used where it matters. | |
661 | + | |
662 | + | |
663 | +small=s.where(n_mon<=threshold) | |
664 | +large=s.where(n_mon>threshold) | |
665 | + | |
666 | + | |
667 | + | |
668 | + | |
669 | +a_small=0.385 | |
670 | +df_small=2.25 | |
671 | + | |
672 | +a_large=0.223 | |
673 | +df_large=1.57 | |
674 | + | |
675 | + | |
676 | +a_tot=0.246 | |
677 | + | |
678 | +df_tot=1.63 | |
679 | + | |
680 | + | |
681 | + | |
682 | + | |
683 | +def Brow_ker_cont_optim(Vlist): | |
684 | + kern_mat=2.*k_B*T_0/(3.*mu)*(Vlist[:,s.newaxis]**(1./df_tot)+\ | |
685 | + Vlist[s.newaxis,:]**(1./df_tot))**2./ \ | |
686 | + (Vlist[:,s.newaxis]**(1./df_tot)*Vlist[s.newaxis,:]**(1./df_tot)) | |
687 | + return kern_mat | |
688 | + | |
689 | + | |
690 | +def Brow_ker_cont_optim_diffusion_adjusted_and_monomer_beta_fuchs(Vlist): | |
691 | + #monomer volume | |
692 | + #r_mon=0.5 #monomer radius | |
693 | + #v_mon=4./3.*s.pi*r_mon**3. | |
694 | + #v_mono already defined as a global variable | |
695 | + #n_mon=Vlist/v_mono #number of monomers in each aggregate | |
696 | + | |
697 | + #print "n_mon is, ", n_mon | |
698 | + | |
699 | + Diff=k_B*T_0/(n_mon*m_mon*beta) #vector with the cluster diffusion coefficients | |
700 | + #which just depends on the cluster size. | |
701 | + | |
702 | + R_list=s.zeros(len(Vlist)) #I initialize the array which will contain the | |
703 | + #radia of gyration | |
704 | + | |
705 | + #threshold=15. | |
706 | + | |
707 | +# small=s.where(n_mon<=threshold) | |
708 | +# large=s.where(n_mon>threshold) | |
709 | + | |
710 | +# a_small=0.36 | |
711 | +# df_small=2.19 | |
712 | + | |
713 | +# a_large=0.241 | |
714 | +# df_large=1.62 | |
715 | + | |
716 | + | |
717 | + R_list[small]=a_small*n_mon[small]**(1./df_small) | |
718 | + | |
719 | + R_list[large]=a_large*n_mon[large]**(1./df_large) | |
720 | + | |
721 | +# R_list[0]=0.5 #special case for the monomer radius | |
722 | + | |
723 | +# m=rho_p*Vlist # this holds in general (i.e. for Vlist !=3.) | |
724 | + ## as long as Vlist is the volume of solid | |
725 | + ##and not the space occupied by the agglomerate structure | |
726 | + | |
727 | + | |
728 | + | |
729 | + c=(8.*k_B*T_0/(s.pi*m))**0.5 | |
730 | + #print 'c is', c | |
731 | + l=8.*Diff/(s.pi*c) | |
732 | + #print 'l is', l | |
733 | + diam_seq=2.*R_list | |
734 | + | |
735 | + g=1./(3.*diam_seq*l)*((diam_seq+l)**3.-(diam_seq**2.+l**2.)**1.5)-diam_seq | |
736 | + | |
737 | + beta_fuchs=(\ | |
738 | + (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]) \ | |
739 | + /(diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]\ | |
740 | + +2.*(g[:,s.newaxis]**2.+g[s.newaxis,:]**2.)**0.5)\ | |
741 | + + 8.*(Diff[:,s.newaxis]+Diff[s.newaxis,:])/\ | |
742 | + ((c[:,s.newaxis]**2.+c[s.newaxis,:]**2.)**0.5*\ | |
743 | + (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]))\ | |
744 | + )**(-1.) | |
745 | + | |
746 | + | |
747 | + ## now I have all the bits for the kernel matrix | |
748 | +# kern_mat=Brow_ker_cont_optim(Vlist)*beta | |
749 | + | |
750 | + | |
751 | + kern_mat=4.*s.pi*(Diff[:,s.newaxis]+Diff[s.newaxis,:])* \ | |
752 | + (R_list[:,s.newaxis]+R_list[s.newaxis,:])*beta_fuchs | |
753 | + | |
754 | + | |
755 | + return kern_mat | |
756 | + | |
757 | + | |
758 | + | |
759 | +def Brow_ker_cont_optim_diffusion_adjusted_and_monomer_beta_fuchs_explicit_smallest(Vlist): | |
760 | + #monomer volume | |
761 | + #r_mon=0.5 #monomer radius | |
762 | + #v_mon=4./3.*s.pi*r_mon**3. | |
763 | + #v_mono already defined as a global variable | |
764 | + #n_mon=Vlist/v_mono #number of monomers in each aggregate | |
765 | + | |
766 | + #print "n_mon is, ", n_mon | |
767 | + | |
768 | + Diff=k_B*T_0/(n_mon*m_mon*beta) #vector with the cluster diffusion coefficients | |
769 | + #which just depends on the cluster size. | |
770 | + | |
771 | + R_list=s.zeros(len(Vlist)) #I initialize the array which will contain the | |
772 | + #radia of gyration | |
773 | + | |
774 | + #threshold=15. | |
775 | + | |
776 | +# small=s.where(n_mon<=threshold) | |
777 | +# large=s.where(n_mon>threshold) | |
778 | + | |
779 | +# a_small=0.36 | |
780 | +# df_small=2.19 | |
781 | + | |
782 | +# a_large=0.241 | |
783 | +# df_large=1.62 | |
784 | + | |
785 | + | |
786 | + R_list[small]=a_small*n_mon[small]**(1./df_small) | |
787 | + | |
788 | + R_list[large]=a_large*n_mon[large]**(1./df_large) | |
789 | + | |
790 | + #Now I introduce a modification for R_list < 5 | |
791 | + | |
792 | + sel=s.where(n_mon==1.) | |
793 | + | |
794 | + R_list[sel]=3.87e-1 | |
795 | + | |
796 | + | |
797 | + sel=s.where(n_mon==2.) | |
798 | + | |
799 | + R_list[sel]=6.39e-1 | |
800 | + | |
801 | + | |
802 | + sel=s.where(n_mon==3.) | |
803 | + | |
804 | + R_list[sel]=7.18e-1 | |
805 | + | |
806 | + sel=s.where(n_mon==4.) | |
807 | + | |
808 | + R_list[sel]=7.48e-1 | |
809 | + | |
810 | + | |
811 | +# R_list[0]=0.5 #special case for the monomer radius | |
812 | + | |
813 | +# m=rho_p*Vlist # this holds in general (i.e. for Vlist !=3.) | |
814 | + ## as long as Vlist is the volume of solid | |
815 | + ##and not the space occupied by the agglomerate structure | |
816 | + | |
817 | + # m=Vlist #since rho = 1. | |
818 | + | |
819 | + c=(8.*k_B*T_0/(s.pi*m))**0.5 | |
820 | + #print 'c is', c | |
821 | + l=8.*Diff/(s.pi*c) | |
822 | + #print 'l is', l | |
823 | + diam_seq=2.*R_list | |
824 | + | |
825 | + g=1./(3.*diam_seq*l)*((diam_seq+l)**3.-(diam_seq**2.+l**2.)**1.5)-diam_seq | |
826 | + | |
827 | + beta_fuchs=(\ | |
828 | + (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]) \ | |
829 | + /(diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]\ | |
830 | + +2.*(g[:,s.newaxis]**2.+g[s.newaxis,:]**2.)**0.5)\ | |
831 | + + 8.*(Diff[:,s.newaxis]+Diff[s.newaxis,:])/\ | |
832 | + ((c[:,s.newaxis]**2.+c[s.newaxis,:]**2.)**0.5*\ | |
833 | + (diam_seq[:,s.newaxis]+diam_seq[s.newaxis,:]))\ | |
834 | + )**(-1.) | |
835 | + | |
836 | + | |
837 | + print "Fuchs beta is, ", beta_fuchs | |
838 | + | |
839 | + ## now I have all the bits for the kernel matrix | |
840 | +# kern_mat=Brow_ker_cont_optim(Vlist)*beta | |
841 | + | |
842 | + | |
843 | + | |
844 | + kern_mat=4.*s.pi*(Diff[:,s.newaxis]+Diff[s.newaxis,:])* \ | |
845 | + (R_list[:,s.newaxis]+R_list[s.newaxis,:])*beta_fuchs | |
846 | + | |
847 | + | |
848 | + return kern_mat | |
849 | + | |
850 | + | |
851 | + | |
852 | + | |
853 | +smolu_kernel=Brow_ker_cont_optim(x) | |
854 | + | |
855 | +print "smoluchowsky kernel is, ", smolu_kernel[0,1] | |
856 | + | |
857 | + | |
858 | +fuchs_kernel=Brow_ker_cont_optim_diffusion_adjusted_and_monomer_beta_fuchs(x) | |
859 | + | |
860 | +print "fuchs kernel is, ", fuchs_kernel[0,1] | |
861 | + | |
862 | + | |
863 | +fuchs_modified_below_5=Brow_ker_cont_optim_diffusion_adjusted_and_monomer_beta_fuchs_explicit_smallest(x) | |
864 | + | |
865 | +print "fuchs_modified_below_5, ", fuchs_modified_below_5[0,1] | |
866 | + | |
867 | + | |
520 | 868 | print "So far so good" |
869 | + | |
870 | + |